I have a little problem, I try to make an online test but I need to shuffle answare so
1 is good answare and 2,3 bad but all time appears a = 1 b = 2 c = 3 and i want something to randomize that like a=2 b=3 c=1 how i can do that?
Code is here:
$result = mysql_query( "SELECT * FROM questions ORDER BY RAND() LIMIT 0,10");
while ($row = mysql_fetch_array($result)) {
$rows[] = $row;
$question_id = $row['question_id'];
$question = $row['question'];
$answare_good = $row['answare_good'];
$answare_badi = $row['answare_badi'];
$answare_badii = $row['answare_badii'];
$number += 1;
echo '<tr>
<td rowspan="3" width="10">'.$number.'</td>
<td rowspan="3" width="70%"><p>'.$question.'</p></td>
<td width="30%" height="33%"><input type="checkbox" name="a1" id="a1">
'.$answare_good.'</td>
</tr>
<tr>
<td width="30%" height="33%"><input type="checkbox" name="a2" id="a2">
'.$answare_badi.'</td>
</tr>
<tr>
<td width="30%" height="33%"><input type="checkbox" name="a3" id="a3">
'.$answare_badii.'</td>
</tr>';
I try something to array shuffle $answare_good & $answare_badi & $answare_badii but i faill.
What about this code:
You would have to specify the value for the checkbox also to be able to get the value of checked answer…
Also move to
PDOor at leastmysqli_*functions asmysql_*functions are deprecated now…EDIT: Also think of using
radioinstead ofcheckbox– assuming user should pick up just one answer. If You want to let the user to pick up more than one (or all three answers), thencheckboxis OK.