deepson2 Posted December 1, 2009 Share Posted December 1, 2009 Hello, I am trying to buid up up quiz section for my site. i have five question on each quiz with radio boxes. E.g 1)Color of the apple is Red true False 2) Color of sky is blue true False and so on. Now i want to pass all the radio boxes value through hidden filed in the different form where i can match those values with correct answer? can we do something like ths that? Here is my code. I am fetching the questions from the database. So, $query= mysql_query( "SELECT * FROM quiz WHERE qid='$qid'"); if(mysql_num_rows($query) > 0) { while($row = mysql_fetch_assoc($query)) { ?> <form action="<?$PHP_SELF;?>" method="post" name="cont"> Q. <?=$row['question'];?></td> </tr> <tr> <? $options=$row['answer']; $qid=$row['qid']; //echo $quizid; $string = explode(",",$options); $total_count=count($string); //echo "$total_count"; ?> <?/* for($i=0;$i<$total_count;$i++) { ?> <input class="radio_button" type="radio" value="<?php echo $string[$i];?>" name="radiobuttonvalue"><?php echo $string[$i];?> <br/> <?php }// End for loop. */ // $string[$i] -contains only true and false as option value. so if we dont want to use it then <input class="radio_button" type="radio" value="true" name="radiobuttonvalue">True <input class="radio_button" type="radio" value="false" name="radiobuttonvalue">False </td> </tr> <?}// End while loop. }// End if(mysql_num_rows($query) }//while ends ?> <tr><td> <input type ="hidden" value="<?php echo $qid; ?>" name="quiz_id"> <input class="radio_button" type="hidden" value="radiobuttonvalue" name="radiobuttonvalue"> I would want to get array of radiobuttonvalue ={ true,false,false,true,false} //the value entered by the user So, my question is can we get different radio boxes value dynamically? and can we pass the all values(radio boxes value) through hidden field with array? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
plznty Posted December 1, 2009 Share Posted December 1, 2009 You could carry the current information through hidden form fields? Unless you created user sessions to save information as you went along. Not much more I can say I'm afraid. Quote Link to comment Share on other sites More sharing options...
deepson2 Posted December 1, 2009 Author Share Posted December 1, 2009 You could carry the current information through hidden form fields? Unless you created user sessions to save information as you went along. Not much more I can say I'm afraid. Thanks for your reply i have following query - SELECT * FROM tf_quiz WHERE qid ='$qid' and date = NOW() So as result i can get 5/or more questions Each time i am getting questions + their options (radio boxes) and each question ll have different set of radio buttons. So how can i store it in session also? please help me. Quote Link to comment Share on other sites More sharing options...
Deoctor Posted December 1, 2009 Share Posted December 1, 2009 u can use the radio buttons like this. <html> <head> <title>Radio Buttons</title> </head> <?PHP $male_status = 'unchecked'; $female_status = 'unchecked'; if (isset($_POST['Submit1'])) { $selected_radio = $_POST['gender']; if ($selected_radio == 'male') { $male_status = 'checked'; } else if ($selected_radio == 'female') { $female_status = 'checked'; } } ?> <body> <FORM NAME ="form1" METHOD ="POST" ACTION ="radioButton.php"> <INPUT TYPE = 'Radio' Name ='gender' value= 'male' <?PHP print $male_status; ?>>Male <INPUT TYPE = 'Radio' Name ='gender' value= 'female' <?PHP print $female_status; ?>>Female <P> <INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Select a Radio Button"> </FORM> </body> </html> now u can evalute the values resulted with the correct ones.. pass the values from this to the other php file Quote Link to comment Share on other sites More sharing options...
deepson2 Posted December 1, 2009 Author Share Posted December 1, 2009 Thanks for your reply ym_chaitu, I am not looking for something like this. Any help?? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.