-1
如何獲取數組格式的無線組值?這是我的發件人(game.php)和接收器(result.php)如何發佈和獲得無線電組數組?
我想用數據庫中正確的答案檢查無線電組元素(是或否),並在正確答案時增加該點。
game.php:
$conn= mysql_connect($servername,$username, $password)or die(mysql_error());
mysql_select_db($database,$conn);
$sql = "SELECT * from questions";
$result=mysql_query($sql);
$num=mysql_numrows($result);
$i=0;
echo("<FORM ACTION='./result.php' METHOD=GET>");
while($i < $num){
$field = array($i => mysql_result($result,$i,"question"));
$j = $i + 1;
echo "<b>[$j] </b>$field[$i]<br>";
echo ("<label>
<input type='radio' name='radioGroup[$i]' value='yes' id='radioGroup_1'>
Yes</label><label>
<input type='radio' name='radioGroup[$i]' value='no' id='radioGroup_1'>
No</label><br>");
$i++;
}
echo "<input type='submit'>";
echo("</FORM>");
echo("<br>");
result.php:
$conn= mysql_connect($servername,$username, $password)or die(mysql_error());
mysql_select_db($database,$conn);
$sqlcode = "SELECT * FROM questions";
$cal=mysql_query($sqlcode);
$num = mysql_numrows($cal);
$m=0;
while ($m < $num){
$user_answer = array($m => $_GET["radioGroup"]);
$m++;
}
$k = 0;
$point = 0;
$sql = "SELECT * from questions";
$result=mysql_query($sql);
while($k < $num){
$answer = array($k => mysql_result($result,$k,"answer"));
if ($answer[$k] == $user_answer[$k]){
$point++ ;
}
echo "puan:";
echo $point;
$k++;
}
是不一樣的問題[這裏](http://stackoverflow.com/ question/11485682/radio-group-information-added-to-array)? – j0k 2012-07-14 18:03:47
我刪除了它。 – Yagiz 2012-07-14 18:06:46
只是一個提示:避免HTML回聲最多。 – rcdmk 2012-07-14 18:22:20