我正在创建一个测验系统。在测验系统中,我在一个页面上显示一个问题。当用户点击下一个按钮时,它显示下一个问题。问题是,我将所有问题存储在数组中。当用户点击问题数组的下一个按钮删除问题并显示错误。问题变量未定义。
**Below code Assign the All Question in array**
<?php
if(!isset($_SESSION["index"]))
{
$_SESSION["index"]=0;
$i=$_SESSION["index"];
//Function Call Find all question
$Questions=Find_All_Question_BY_Quiz_ID($Quiz_Item["Quiz_Item_ID"]);
//$Declare the array;
static $Question=array();
while($Questionss=mysqli_fetch_assoc($Questions))
{
$Question[]=$Questionss;
$index++;
echo $index;
}
$i=$_SESSION["index"]+1;
echo "1:index+1 is equal to ".$i;
$Quiz=Show_One_By_One_Question($Question);
echo $Quiz;
}
else
{
//Its craete function show question in html form
$Quiz=Show_One_By_One_Question($Question);
echo $Quiz;
$_SESSION["index"]=0;
}
?>
代码下方显示输出
<form action="QuizPage.php">
<input type="submit" class="btn btn-danger" value="Click me">
</form>
感谢您的帮助