laserlight;10960038 wrote:I am little confused, but humour me: why would [man]shuffle/man not work for you?
Thanks for your suggestion laserlight i'll put that in mind.
Now I face another problem, but I'm not sure if I will post it here or not because this problem is still connected with this code. Just inform me guys if I need to create another thread for this.
Here's the problem, I customized my code, I add a radio button in each option but every time I tried to refresh the page, the options has been rearranged but the selected radio remain on same line.
Is there anyway, that if I will refresh the page, the selected radio button will follow as well to the new random arrangement of the selected option.
I hope you understand me... LOL... But I really need your help.
Here's my sample code below:
<?
$selectquestions = mysql_query("select * from tblquestions where ndex = '1'",$conn);
while ($dataquestion = mysql_fetch_array($selectquestions)){
$optiona = '<input type="radio" value="A" name="answers'.$ndexanswerstoquestion.'" id="answers'.$ndexanswerstoquestion.'A">'.$dataquestion['fldoptiona'];
$optionb = '<input type="radio" value="B" name="answers'.$ndexanswerstoquestion.'" id="answers'.$ndexanswerstoquestion.'B">'.$dataquestion['fldoptionb'];
$optionc = '<input type="radio" value="C" name="answers'.$ndexanswerstoquestion.'" id="answers'.$ndexanswerstoquestion.'C">'.$dataquestion['fldoptionc'];
$optiond = '<input type="radio" value="D" name="answers'.$ndexanswerstoquestion.'" id="answers'.$ndexanswerstoquestion.'D">'.$dataquestion['fldoptiond'];
}
$characters = array($optiona,$optionb,$optionc,$optiond);
while(count($keys) < 4) {
$x = mt_rand(0, count($characters)-1);
if(!in_array($x, $keys)) {
$keys[] = $x;
}
}
foreach($keys as $key){
$random_chars .= $characters[$key].'<br>';
}
?>
Thanks in advance pro php masters!