watthehell Posted July 5, 2007 Share Posted July 5, 2007 Hi can anybody help me with PHP code for a quiz ???? I need to fetch all the questions and answers from DB with radio button ??? in each page i need to show 5 questions (total 20 questions) i.e. 4 page ?? Can anybody please guide me a logic for this part and also with Database how must it be designed ????????????????????? please , this is my college project please please please thanking in advance... Quote Link to comment https://forums.phpfreaks.com/topic/58536-php-quiz/ Share on other sites More sharing options...
RichardRotterdam Posted July 5, 2007 Share Posted July 5, 2007 Well you need to do a couple of things. 1)you will need to set up the the correct tables for you database. 2)you will need the correct sql querries to retrieve the data(I recommend mysql or postgress for your database because ms acces is just terrible) 3)create your php code that will show your data in HTML. if you allready have some of this post your code so others can help you out Quote Link to comment https://forums.phpfreaks.com/topic/58536-php-quiz/#findComment-290332 Share on other sites More sharing options...
bbaker Posted July 5, 2007 Share Posted July 5, 2007 no offense, but if this is your college project, shouldn't you have been paying attention in class? This isn't really that difficult. The way I'd set up up the database: One table for each of the 20 questions, one table for answer options. questions: id = int(2) NOT NULL <== KEY question = longtext answers: id = int(2) NOT NULL auto_increment <== KEY q_id = int(2) NOT NULL a_options = longtext a_correct= char(3) NOT NULL default 'NO' <== OR enum('YES','NO') NOT NULL default 'NO' For your first page, show only the 5 questions. query each individual question, display it, then query the answer options (a_options) and display them as radio buttons, completes the questions and clicks the "Next 5 Q's" or "Submit" button, store the user's answers in sessions and show the next 5 Q's....repeat until the last page. Then, I assume you need to show the user their score (X out of 20 Q's correct). From the session info that you saved along the way, check it against the correct questions in the database. Quote Link to comment https://forums.phpfreaks.com/topic/58536-php-quiz/#findComment-290343 Share on other sites More sharing options...
per1os Posted July 5, 2007 Share Posted July 5, 2007 no offense, but if this is your college project, shouldn't you have been paying attention in class? This isn't really that difficult. They actually offer PHP classes in school....lol thats messed up. I never thought to see the day. All I was able to do was PERL and Java and C++.. Oh well PHP really was better learnt without a teacher, teachers really are dumb for the most part when it comes to the webbased programmed as most of them grew up with C and Cobalt. Fun stuff. But agreed, this stuff could of been easily read or figured out with a little attention in class....but then again I never paid attention in any programming class...actually I never even want to class...come to think of it I still got a 4.0....weird stuff. Quote Link to comment https://forums.phpfreaks.com/topic/58536-php-quiz/#findComment-290382 Share on other sites More sharing options...
watthehell Posted July 6, 2007 Author Share Posted July 6, 2007 aahhh well.. it is true i never paid attention in class , and thanks all for the replies.... i did wat mr bbaker had posted.... i designed the db with two tables one for question and other for answer... i forgot to say be4, the questions and answer to be posted is dynamic.... errr my teacher will post that .... but main point is when we create a answers table, we have to show option for correct answer too.. will the radio button will work on this... i'm confused Suppose if there are 4 answers and the third one is correct.. how will we know which is correct ... please help on this... and secondly.. in the front end can u tell me how to write the code for fetching the answer..if i am not mistaken the answer must be fetched from loop, right or wrong... ??? and while desgining html how shall i do it ?? please help please Quote Link to comment https://forums.phpfreaks.com/topic/58536-php-quiz/#findComment-290971 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.