How to store SQL query result in a variable using PHP?
<p>I want to store the first query result in a variable and use the first query result as a value in the second query.</p>

<p>Currently the second query works on its own. I am just having difficulties getting the first one to work.</p>

<pre><code>$var = array();$idorigin = $conn-&gt;prepare("SELECT id_stop FROM stops WHERE
stopname = '$value1'");
$idorigin-&gt;execute()
$var[] = $idorigin['id_Stop'];
echo $var;

$stmt = $conn-&gt;prepare("SELECT id_stop, scheduletime FROM schedule 
WHERE scheduletime &gt;= '$time' AND id_stop = '8'
LIMIT 6;");


$stmt-&gt;execute();
echo $stmt;
</code></pre>