jrodd32 Posted January 22, 2007 Share Posted January 22, 2007 I have a scrambled test that I need to display one at a time. However it is displaying all at once. How would I control this?ThanksBy the way, I am using sessions[code]<?php$qnum=0;for($count=0;$count<100;$count++) #count of number of questions{ if($qnum>99) #keeps the question number in the proper range of 0-99 $qnum=$qnum-99; else $qnum=$qnum; if(in_array($qnum,$used )) #checks to see if current question number is already in the array of used numbers { $qnum=$qnum+1; $question=$tQ[$qnum]; $used[$count]=$qnum; } else { $question=$tQ[$qnum]; $used[$count]=$qnum; }echo("Count: $count <br>" . "Random Number: $skip <br>" . "Question Number: $qnum <br>" . "$question <br>");$qnum=$qnum+$skip;}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/35258-data-control-on-a-test/ Share on other sites More sharing options...
Jessica Posted January 22, 2007 Share Posted January 22, 2007 Don't use a for loop, just display the one you want. Quote Link to comment https://forums.phpfreaks.com/topic/35258-data-control-on-a-test/#findComment-166565 Share on other sites More sharing options...
jrodd32 Posted January 22, 2007 Author Share Posted January 22, 2007 Well my ultimate goal is to have the questions show up one at a time and the user select their answer and hit submit to save the answer and continue to the next question. Is that possible without making a hundred different pages? Do I need to redo my logic completely? Quote Link to comment https://forums.phpfreaks.com/topic/35258-data-control-on-a-test/#findComment-166573 Share on other sites More sharing options...
Jessica Posted January 22, 2007 Share Posted January 22, 2007 Store what question they're on in the session, then move onto the next one. Quote Link to comment https://forums.phpfreaks.com/topic/35258-data-control-on-a-test/#findComment-166575 Share on other sites More sharing options...
jrodd32 Posted January 24, 2007 Author Share Posted January 24, 2007 I read in my php book and I am not sure how saving the question will help, I need to be able to print the 100 questions consequtively, but one at a time following the continue button being pushed Quote Link to comment https://forums.phpfreaks.com/topic/35258-data-control-on-a-test/#findComment-168269 Share on other sites More sharing options...
Jessica Posted January 24, 2007 Share Posted January 24, 2007 Have the page get the number out of the session. If there is no number, start with 1. So show one. Store the number 1 in the session. When they click the continure button, show the page again. 1 is in the session, so go on to 2. Continue until done. Quote Link to comment https://forums.phpfreaks.com/topic/35258-data-control-on-a-test/#findComment-168277 Share on other sites More sharing options...
jrodd32 Posted January 24, 2007 Author Share Posted January 24, 2007 I am not completely sure I understand what you are saying. Are you saying to save the current question number as a variable then print that question? If so what would be the code to do something like that? Namely how would I control that on continue the next question would appear? Quote Link to comment https://forums.phpfreaks.com/topic/35258-data-control-on-a-test/#findComment-168304 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.