Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to post and get radio group arrays?
    primarykey
    data
    text
    <p>How can I get the values of the radio groups in an array format? Here is my sender(game.php) and receiver(result.php)</p> <p>I wanted to check the radio group elements(yes or no) with the correct answers from database and increase the point if its correct.</p> <p>game.php:</p> <pre><code> $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("&lt;FORM ACTION='./result.php' METHOD=GET&gt;"); while($i &lt; $num){ $field = array($i =&gt; mysql_result($result,$i,"question")); $j = $i + 1; echo "&lt;b&gt;[$j] &lt;/b&gt;$field[$i]&lt;br&gt;"; echo ("&lt;label&gt; &lt;input type='radio' name='radioGroup[$i]' value='yes' id='radioGroup_1'&gt; Yes&lt;/label&gt;&lt;label&gt; &lt;input type='radio' name='radioGroup[$i]' value='no' id='radioGroup_1'&gt; No&lt;/label&gt;&lt;br&gt;"); $i++; } echo "&lt;input type='submit'&gt;"; echo("&lt;/FORM&gt;"); echo("&lt;br&gt;"); </code></pre> <p>result.php:</p> <pre><code> $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 &lt; $num){ $user_answer = array($m =&gt; $_GET["radioGroup"]); $m++; } $k = 0; $point = 0; $sql = "SELECT * from questions"; $result=mysql_query($sql); while($k &lt; $num){ $answer = array($k =&gt; mysql_result($result,$k,"answer")); if ($answer[$k] == $user_answer[$k]){ $point++ ; } echo "puan:"; echo $point; $k++; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload