venkyzrocks Posted June 13, 2011 Share Posted June 13, 2011 Hi, I'm trying to implement a quiz but i don't want all the questions on a single page.i want one question appearing after another (similar to a image sideshow) and need to capture that data in MYSQL database.I have got the basics done like all the questions on a single page.What I need to do is get the questionnaire sideshow so that the questions appear one after the other.Can anyone tell me if they have done a similar thing or have found source codes.Help is highly appreciated.Thanks Quote Link to comment https://forums.phpfreaks.com/topic/239248-quiz-slidehsow-with-questions-and-need-to-capture-the-answers/ Share on other sites More sharing options...
ManiacDan Posted June 13, 2011 Share Posted June 13, 2011 Look into the PHP session, it is how you maintain state in an applcation. Print question 1, and have the answer "submit" to the same page. Store the "current" question in the session (or in a hidden variable in the form itself). Print the next question when you receive the answer to the previous question. It can all be done in one page: $nextQuestion = 1; if ( isset( $_POST['answer'] ) ) { //record their answer in the db. $nextQuestion = $_POST['questionId'] + 1; } //select and display the question in $nextQuestion, including the questionId in the form. //If there is no next question (you've hit the end of the test), display the score or "thank you" or whatever As you can see, you don't need sessions for this, but you could use the session as a temporary data store for the answers until the quiz is complete (avoiding a round-trip to the database). -Dan Quote Link to comment https://forums.phpfreaks.com/topic/239248-quiz-slidehsow-with-questions-and-need-to-capture-the-answers/#findComment-1229130 Share on other sites More sharing options...
venkyzrocks Posted June 13, 2011 Author Share Posted June 13, 2011 Thanks for the prompt reply but I'm trying to get something similar tho this done http://net.tutsplus.com/quizzes/nettuts-quiz-1-beginner-css/ Anymore ideas.Thanks once again Quote Link to comment https://forums.phpfreaks.com/topic/239248-quiz-slidehsow-with-questions-and-need-to-capture-the-answers/#findComment-1229138 Share on other sites More sharing options...
ManiacDan Posted June 14, 2011 Share Posted June 14, 2011 Look into AJAX. It's much more complicated, but follows the same basic structure I set out above. Quote Link to comment https://forums.phpfreaks.com/topic/239248-quiz-slidehsow-with-questions-and-need-to-capture-the-answers/#findComment-1229682 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.