Hey, I made the following code that checks the answers of a form:
<?PHP include 'connect.php'; $points = 0; foreach($_POST as $id => $answer){ $result = mysql_query("SELECT id, ans FROM questions WHERE id = '".$id."'"); $row = mysql_fetch_array($result); if($answer == $row['ans']) { $points++; } } echo "Your score: $points"; ?>
The problem is that it makes a sql query for every question, which makes the script a bit slow...
Is there a way to make a single sql query that select all the answers?