How to create this app (fetching questions & answers MYSQL)
Posted: Wed May 25, 2011 6:34 pm
I've just learned the basics of MySQL last night and made a simple app (where a user enters a song name, song title, and rating (out of 5) and it displays the list of songs with the highest rated songs first).
So I decided I wanted to make something similar yet slightly more complicated and I'm not sure if I'm on the right track. Basically it's a "flash card" game where:
- The user gets to input their own questions and answers into a simple form, which would then go into an MySQL table with 2 columns, questions and answers
- A new page where the user see's random question, must input an answer, if the answer matches goes to next question otherwise gives error
Now I'm confused as to how to go about making this. I was thinking of making some session variables and then do something along the lines of
and then make some PHP that might do something like this:
So am I just completely off the wall with this, how would I make such an app? How would I make it, for example, fetch new questions?
So I decided I wanted to make something similar yet slightly more complicated and I'm not sure if I'm on the right track. Basically it's a "flash card" game where:
- The user gets to input their own questions and answers into a simple form, which would then go into an MySQL table with 2 columns, questions and answers
- A new page where the user see's random question, must input an answer, if the answer matches goes to next question otherwise gives error
Now I'm confused as to how to go about making this. I was thinking of making some session variables and then do something along the lines of
Code: Select all
$display_query = "SELECT * FROM questions";
$display = mysqli_query($connection, $display_query);
while ($row = mysqli_fetch_array($display)) {
$_SESSION['question'] = $row[0];
}Code: Select all
if ($_SESSION['answer'] != $row[1]) {
echo "error, try again"
} else {
// I would write something here to grab the next question
}
So am I just completely off the wall with this, how would I make such an app? How would I make it, for example, fetch new questions?