Ramtree Posted July 9, 2009 Share Posted July 9, 2009 i have a admin page where the admin submits the questions, options for answers, and the correct answer into a form. the data will then be recorded into a table in mysql called quiz. there will be another page where the latest questions submited by the admin will be displayed for the participants to answer. the participants will then submit their answers in the forms. those who answer correctly, their information will go into the quiz_correct_response table. those who get wrong will go into the quiz_incorrect_response. then, there will be a function to random out the winner. right now, all of the correct and incorrect responses are recorded into the 2 tables only. i need to random out the winners for different questions. how should i go about doing it? should i have the code to create new tables for the questions everytime the admin submits a new one? i need a simple and organise way of doing this. please help me! thanks in advance. hope u can understand this. ask questions if you need to clarify somethings. Quote Link to comment https://forums.phpfreaks.com/topic/165351-help-for-php-pop-quiz/ Share on other sites More sharing options...
AviNahum Posted July 9, 2009 Share Posted July 9, 2009 correct me if I'm wrong, you want to select a random winner from the quiz_correct_response table? Quote Link to comment https://forums.phpfreaks.com/topic/165351-help-for-php-pop-quiz/#findComment-872005 Share on other sites More sharing options...
ignace Posted July 9, 2009 Share Posted July 9, 2009 SELECT * FROM quiz_correct_response ORDER BY rand() LIMIT 1 Quote Link to comment https://forums.phpfreaks.com/topic/165351-help-for-php-pop-quiz/#findComment-872019 Share on other sites More sharing options...
Ramtree Posted July 9, 2009 Author Share Posted July 9, 2009 correct me if I'm wrong, you want to select a random winner from the quiz_correct_response table? yes. but since the questions are constantly being updated, i need to random pick a winner for every single questions. take it like a lucky draw, you take part in a lucky draw and then the winner is randomly picked out. then the admin submits new questions for a new lucky draw, and another winner is randomly picked out. right now, the correct responses for all the lucky draws are in one single table, which makes it hard to random out the winner for the different lucky draws. Quote Link to comment https://forums.phpfreaks.com/topic/165351-help-for-php-pop-quiz/#findComment-872024 Share on other sites More sharing options...
ignace Posted July 9, 2009 Share Posted July 9, 2009 correct me if I'm wrong, you want to select a random winner from the quiz_correct_response table? yes. but since the questions are constantly being updated, i need to random pick a winner for every single questions. take it like a lucky draw, you take part in a lucky draw and then the winner is randomly picked out. then the admin submits new questions for a new lucky draw, and another winner is randomly picked out. right now, the correct responses for all the lucky draws are in one single table, which makes it hard to random out the winner for the different lucky draws. So you want to pick a winner for each quiz: SELECT * FROM quiz_correct_response WHERE quiz_id = $id ORDER BY rand() LIMIT 1 Quote Link to comment https://forums.phpfreaks.com/topic/165351-help-for-php-pop-quiz/#findComment-872030 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.