I hope someone can help me out on this one. I have been trying to get it work since last night. I am making an application where I can add a quiz.
The quiz has questions. Each question has a certain number of choices and out of those choices one of them will be the right answer.
This is what I have thought of:
page1.php: Admin enters the question. Then he enters the number of choices he would like for that question.
page2.php: A table is created dynamically with 2 colomns. One with radio buttons and the other with text boxes. The number of rows will be determined by the value he entered on page1.php
He will enter the choices text in the textbxes and click on a radio button for te right answer.
He clicks on submit and goes to another page asking him if he wants to add another question to the quiz. If yes he goes to Page1.php.
Now, I am stuck.
I have a table called Choices which stores all the choices of the question with the questionID as a foreign key.
Code: Select all
CREATE TABLE Choices(
Choice VARCHAR(50),
flag VARCHAR(3),
FOREIGN KEY (QuestionId) REFERENCES Questions(QuestionId));Now I created a dynamic page with table and 2 colmuns and rows. The text fields are in an array. How do I insert these values into the MySQL database. I read about the function serialize(), I read about implode()..but I tried them, it does not do what I would want it to do.
This is how I would like it to look:
Code: Select all
<HTML>
<HEAD><TITLE>My First PHP Project</TITLE></HEAD>
<BODY>
<form action='' method='post'>
<?php
echo("<TABLE>");
echo( "\n<TR BGCOLOR=\"#E0FFFF\">");
echo("<TH>" . radiobutton. "</TH>");
echo("<TH>" . textchoice . "</TH>");
echo("</TR>");
for($j = 1; $j <= 5; $j++) {
<tr>
<td><input type="radio" id=i name="radiobutton[]" value="radiobutton"></td>
<td><input type="text" id=i name="textfield[]"></td>
</tr>
<?php
}
echo("</TABLE>");
?>
<p align="center"><input type="submit" value="Submit" name="Submit">
<input type="reset" value="Reset" name="B2"></p>
</form>
</BODY>
</HTML>Code: Select all
flag choice questionID(tis is passed from the previous page)
0 fruit? 1
0 veg? 1
1 icecream? 1feyd | Please review how to post code using
Code: Select all
andCode: Select all
tags. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]