The arrays are,
questions[]
answers[]
scores[].
questions should be inserted into question table whose structure is,
question_id - int, auto_inc
question- varchar(255)
answers should be inserted into answers. Its structures is,
answer_id - int, auto_inc
answer - varchar(255)
score - int
question_id - int, fk
i tried using foreach.
Code: Select all
foreach($questions as $question)
{
mysql_query("INSERT INTO questions SET question = $question");
$question_id = mysql_insert_id();
foreach($answers as $answer)
{
mysql_query("INSERT INTO answers SET answer= $answer");
$answer_id = mysql_insert_id();
foreach($scores as $score)
{
mysql_query("UPDATE answers SET score= $score WHERE answer_id = $answer_id");
}
}
}
Thanks in advance