I want to store the first query result in a variable and use the first query result as a value in the second query.
Currently the second query works on its own. I am just having difficulties getting the first one to work.
$var = array();$idorigin = $conn->prepare("SELECT id_stop FROM stops WHERE
stopname = '$value1'");
$idorigin->execute()
$var[] = $idorigin['id_Stop'];
echo $var;
$stmt = $conn->prepare("SELECT id_stop, scheduletime FROM schedule
WHERE scheduletime >= '$time' AND id_stop = '8'
LIMIT 6;");
$stmt->execute();
echo $stmt;
You could use something like this for your first statement :
$req = $conn->prepare("SELECT id_stop FROM stops WHERE stopname = :value");
$req->execute(array('value' => $value1));
$result = $req->fetchAll();
$req->closeCursor();
var_dump($result);
Hope this helps
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments