日期:2014-05-17  浏览次数:20548 次

在线答题,如何取出第二道题?
本页为select.php
<?php 

  前面是连接数据库

while($row=mysql_fetch_array($myquery)){
$array[]=$row[question];
$arrayA[]=$row[optionA];
$arrayB[]=$row[optionB];
$arrayC[]=$row[optionC];
$arrayD[]=$row[optionD];

}
$i=0;
$cnt=count($array);
echo "".$array[$i]."";


  ?> 
   
  ````````````

  <form name="form1" method="post" action ="select.php">

  <input type="radio" id= "style1" name="style1" value="A" />
  <laber for="style"><?php echo "A." . $arrayA[$i]."";?></laber>
<input type="radio" id= "style1" name="style1" value="B" />
<laber for="style"><?php echo "B." . $arrayB[$i]."";?></laber>
<input type="radio" id= "style1" name="style1" value="C" />
<laber for="style"><?php echo "C." . $arrayC[$i]."";?></laber>
<input type="radio" id= "style1" name="style1" value="D" />
<laber for="style"><?php echo "D." . $arrayD[$i]."";?></laber><br>

<input type="submit" value="提交" id="submit" name="submit"/>


<?php

if($_POST['submit']!=""){
$array[$i]=$array[$i+1];
$arrayA[$i]=$arrayA[$i+1];
$arrayB[$i]=$arrayB[$i+1];
$arrayC[$i]=$arrayC[$i+1];
$arrayD[$i]=$arrayD[$i+1];

}

问题1.我想在点击提交之后取出下一个题目,请问之后应该如何操作?
问题2.我想通过创建一个$_SESSION['']=$_POST['name']的方式保存每次用户提交答题的答案,直到答题结束为止,但是每次提交答案后SESSION中只保存了当前提交的答案,请问SESSION是否只能保存当前答案?

------解决方案--------------------
你没有传递题号,所以你不知道现在答的是第几题
当然也就不能保存答案了