Login Register


Result Shuffling problem in Mysql filter_list
Author
Message
Result Shuffling problem in Mysql #1
Well I've this script which fetches questions from Mysql database according to the user chosen subject, now the question must appear randomized to the user so that they might not memorize it or guess it but I've tried to implement this feature many times and I've been failing. It seems that this Submit button is causing the problem as when it refreshes the page the question gets changed so as the options and in turn the answer becomes wrong..

Code:
//Ex094's Script $com = "select * from mcqs where subject LIKE '%$sub%' ORDER BY RAND() LIMIT $start, $limit"; $query=mysql_query($com); while($query2 = mysql_fetch_array($query)) { echo "Q) " . $query2['question'] . "</br>"; $question = $query2['question']; $opt1 = $query2['opt1']; $opt2 = $query2['opt2']; $opt3 = $query2['opt3']; $opt4 = $query2['opt4']; $ans = $query2['ans']; echo "<form id='formstyle' method='post' action=''>"; echo "<ul id='center'>"; echo "<li><input type='radio' name='answer' value='$opt1' id='choice'>".$query2['opt1']."</input></br></li>"; echo "<li><input type='radio' name='answer' value='$opt2' id='choice'>".$query2['opt2']."</input></br></li>"; echo "<li><input type='radio' name='answer' value='$opt3' id='choice'>".$query2['opt3']."</input></br></li>"; echo "<li><input type='radio' name='answer' value='$opt4' id='choice'>".$query2['opt4']."</input></br></li>"; echo "</ul>"; echo "</br><input id='1' type='submit' value='Submit' name='submit' style='margin-bottom:15px;'></form>"; if(isset($_POST['submit'])) { $_POST['answer'] == " "; if($_POST['answer'] == $ans) { echo "<h3>Correct!</h3>"; } else { echo "<h3>Wrong</h3>"; echo "The correct answer was <b>$ans</b> </br>"; } } }

I don't understand what else should I do, Immediate help would be appreciated Smile
My Blog: http://www.procurity.wordpress.com
Donations: 1HLjiSbnWMpeQU46eUVCrYdbkrtduX7snG






Messages In This Thread
Result Shuffling problem in Mysql - by Ex094 - 04-11-2014, 07:00 PM



Users browsing this thread: 1 Guest(s)