love_bug Posted September 15, 2010 Share Posted September 15, 2010 Hi guys, I am creating a quiz system for my personal site, I am done with all the quiz questions creating part, but I am stuck with something like... user taking a random sql generated quiz and submitting it.. Here's randomly generated sql quiz, even the answers are in random order: <form method="post"> <b>1. What is color or sky</b> <ol> <li><input name="question_3_answer" type="radio" value="6" /> sky</li> <li><input name="question_3_answer" type="radio" value="8" />blue</li> <-- true <li><input name="question_3_answer" type="radio" value="3" />red</li> </ol> <b>2. What is name of my cat</b> <ol> <li><input name="question_6_answer" type="radio" value="9" />brat</li> <--true <li><input name="question_6_answer" type="radio" value="7" />rat</li> </ol> <b>3. What is name of my pet</b> <ol> <li><input name="question_18_answer" type="radio" value="9" />cat</li> <--true <li><input name="question_18_answer" type="radio" value="7" />dog</li> </ol> </form> Now this is tricky part for me is.. receiving these data in another page.. since it's randomly generated questions, how do I know which question it is? here's example I've tried : $list_all_quiz_questions = $db->get_row("SELECT question_id, its_true_ans_id FROM question_table WHERE quiz_group = 'ef23fsdfers3e' "); $i = 1; foreach ($list_all_quiz_questions as $myquestion) { $answer.$i == $_POST["question_".$myquestion->question_id."_answer"]; //?????????? not working lol ;(( $i++ } Link to comment https://forums.phpfreaks.com/topic/213499-accepting-post-data-which-i-dont-know/ Share on other sites More sharing options...
kickstart Posted September 15, 2010 Share Posted September 15, 2010 Hi Think your basic idea should work, but you are using a == (comparison) in what looks like an assignment, and $answer.$i will concatenate the values of $answer and $i, which doesn't look to be useful. Not sure what db wrapper you are using but get_row looks like it will return a single row whcih doesn't really go with what $list_all_quiz_questions suggests. All the best Keith Link to comment https://forums.phpfreaks.com/topic/213499-accepting-post-data-which-i-dont-know/#findComment-1111407 Share on other sites More sharing options...
love_bug Posted September 15, 2010 Author Share Posted September 15, 2010 wow.. a single mistake lol.. thankx for reply, I am using ez_mysql_warper.. i didn't pay attention to that part "$db->get_row".. just changed it to "$db->get_results(" and worked like charm.. thanks for help.. "==" part isn't that important cos i probably double typed that when I posted. thankx again. Link to comment https://forums.phpfreaks.com/topic/213499-accepting-post-data-which-i-dont-know/#findComment-1111417 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.