Creating a loop in PHP using Array with SQL values in combination with manual control through button -


i trying create loop in can create set 10 random questions questions table in sql database.

when have these, want store them in list further use, , add them table in database called didwell. in table saved whether answered question right.

$this->connect();  // 10 random questions , put them elsewhere in database , make list          for($i = 1; $i <= 10; $i++)         {         $question = mysql_query("select questionnumber, question, goodanswer, badanswer `question` subjectid = '$subject' order rand() limit 1");         $question = mysql_fetch_array($question);         $question = $question['questionnumber', 'question', 'goodanswer', 'badanswer'];                     $insertquestion = mysql_query("insert didwell (`username`, `questionnumber`, `answer`) values ('$username','questionnumber','3')"); 

in order see if person pressed right button, want compare button value goodanswer value stored in list earlier on.

// question time, fill in labels , buttons

for($o = 1; $o <= 10; $o++)         {             $thequestionnumber = 'questionnumber'[i];             $thequestion = 'question'[i];             $thegoodanswer = 'goodanswer'[i];             $thebadanswe = 'badanswer'[i];              $filledinanswer = <"submitbtn" type="submit" value="answer"> 

if indeed correct answer, value in database should changed 1. afterwards should show next page , go through next question array

// check answere right or wrong

            // if yes              if ($filledinanswer == $thegoodanswer)             {                 $sql = mysql_query("update didwell set answer = 1 questionnumber = '$questionnumber' , username = '$username' ");                 $nextscreen();             }              // if not              else             {                 $nextscreen();             }         }      } } 

my biggest concern loop try use filling in label, button , textfield. idea start new loop when button pressed max of 10 loops.

so wondering is possible make loop "for each time button pressed"? or should not use loop @ all? i'm new php , not great programmer in general, managed make things before reading books , reading other people's questions , answers on here. hope learn again experiences , expertise of you.

looking forward hear you!


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -