hi am building a quiz system and basically i have my questions in an array called $questions and answers in an array $answers i have created an interface in html php to add data questions and answers into this arrays
$question1 = $_POST['question1'];
$question2 = $_POST['question2'];
$ans1 = $_POST['ans1'];
$ans2 = $_POST['ans2'];
$questions = array();
array_push($questions,$question1,$question2);
$answers = array();
array_push($answers,$ans1,$ans2);
so to insert this values in a database this is what i do
$quest_count = count($questions);
for ($i=0;$i<=$quest_count;$i++)
{
$query = "INSERT INTO quiz (question,answer) VALUES ('$questions[$i]','$answers[$i]')";
$result = mysql_query($query);
}
so my problem is this the for loop should add two rows in the database since the questions array contains two values question1 and question2 but it only adds one row. can anyone help me out on this am sure its ('$questions[$i]','$answers[$i]') part that has a problem.
thanks
{$questions[$i]}or". $questions[$i] . "