I created an array and stored it inside a $_SESSION variable, now I want to include that array inside a MySQL select statement to get more infos depending on p, which is included in my URL. My code is included inside a HTML page, which is completely empty except for necessary HTML and of course session_start, so this is not the problem. The code looks like that:
<?php
$p = $_GET["p"];
var_dump($_SESSION['questions'][$p]);
include("../script/db_connect.php");
$p = $_GET["p"];
$select_right_question = "select * from questions where id = '{$_SESSION['questions'][$p]}'";
$question_infos = mysqli_query($con, $select_right_question);
while ($row = mysqli_fetch_assoc($question_infos)) {
echo $row["question"] . '</br>'
. $row["right_answer"] . '</br>'
. $row["answer2"] . '</br>'
. $row["answer3"] . '</br>'
. $row["answer4"];
}
mysqli_close($con);
?>
I already tested it and the main issue is the following line:
$select_right_question = "select * from questions where id = '{$_SESSION['questions'][$p]}'";
What is the correct way to include the SESSION variable here?