在定时器关闭之前,while循环后定义的div和按钮都不可见。我不知道是什么问题。我在php之外尝试了它,但它仍然没有显示任何内容。在添加这个PHP代码之前,一切都运行良好,以显示从数据库中随机选择的一些不同的问题。有人请帮帮我。我是php的新手。非常感谢。
<?php
$record=array(); //creating array to keep record of Q_ID of questions
for($count=1;$count <= $NoOfQuestion;$count++)// to display $NoOfQuestion number of questions
{
while(1)
{
$sql=mysql_query("select * from questions order by RAND()");
$result = mysql_fetch_array($sql);
$temp=0;
if(count($record)>=1)
{
for($i=1;$i<=$count;$i++)
{
if($record[$i]==$result['Q_ID'])
$temp++;
}
}
if($temp==0)
{
$text ='Question '.$count. '. '.$result['Question'];
echo $text;
return 0;
}
else
return 1;
}
echo'</div>';
echo'<div id="option"></div>';
echo'<div id="buton">';
echo'<input type="submit" name="Previous" value="previous" id="previous"/>';
echo'<input type="submit" name="Next" value="next" id="next"/>';
echo'<input type="submit" name="Review" value="review" id="review"/>';
echo'<input type="submit" name="Submit" value="submit" id="submit"/>';
echo'</div>';
echo'<div id="div3">3</div>';
echo'</div>';
echo'</form>';
}
?>
答案 0 :(得分:0)
修改你的代码......
echo'<div id="option"></div>';
echo'<div id="buton">';
echo'<input type="submit" name="Previous" value="previous" id="previous"/>';
echo'<input type="submit" name="Next" value="next" id="next"/>';
echo'<input type="submit" name="Review" value="review" id="review"/>';
echo'<input type="submit" name="Submit" value="submit" id="submit"/>';
echo'</div>';
echo'<div id="div3">3</div>';
答案 1 :(得分:0)
尝试
<?php
$record=array(); //creating array to keep record of Q_ID of questions
for($count=1;$count <= $NoOfQuestion;$count++)// to display $NoOfQuestion number of questions
{
while(1)
{
$sql=mysql_query("select * from questions order by RAND()");
$result = mysql_fetch_array($sql);
$temp=0;
if(count($record)>=1)
{
for($i=1;$i<=$count;$i++)
{
if($record[$i]==$result['Q_ID'])
$temp++;
}
}
if($temp==0)
{
$text ='Question '.$count. '. '.$result['Question'];
echo $text;
return 0;
}
else
return 1;
}
}
echo '</div>';
echo '<div id="option"></div>';
echo '<div id="buton">';
echo '<input type="submit" name="Previous" value="previous" id="previous"/>';
echo '<input type="submit" name="Next" value="next" id="next"/>';
echo '<input type="submit" name="Review" value="review" id="review"/>';
echo '<input type="submit" name="Submit" value="submit" id="submit"/>';
echo '</div>';
echo '<div id="div3">3</div>';
echo '</div>';
echo '</form>';
?>