In my code for a quiz program im making, if the user_quiz_right and user_quiz_wrong columns in the database are both "2", it always says I got 2 right and 3 wrong. Even if for the last question I got it right (so it should by 3 right, 2 wrong). The "Questions_quiz" field in the database is 5, so there are 5 questions per quiz. What I want to happen is for it to be reported correctly, so even if on the last question you get it right, it will report 3 right 2 wrong rather than 2 right 3 wrong no matter what. Thanks
PHP Code:
<?php
/***************************************************************************
 *                               quizzer.php
 *                            -------------------
 *   begin                : Tuesday, Sept 18, 2004
 *   copyright          : (C) 2004 Battye @ CricketMX.com
 *   email                : cricketmx@hotmail.com
 *
 *   $Id: quizzer.php, v2.000.0.00 2004/03/12 21:18:13 battye Exp $
 *
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/
 
define('IN_PHPBB'true);
define('SHOW_ONLINE'true);
$phpbb_root_path './';
include(
$phpbb_root_path 'extension.inc');
include(
$phpbb_root_path 'config.'.$phpEx);
include(
$phpbb_root_path '/includes/constants.'.$phpEx);
include(
$phpbb_root_path 'common.'.$phpEx);

//
// Start session management
//
$userdata session_pagestart($user_ipPAGE_PROFILE);
init_userprefs($userdata);
//
// End session management
//

$id $HTTP_POST_VARS['Hidden'];
$idm $HTTP_POST_VARS['Id'];
$ua $HTTP_POST_VARS["$idm"];
$next $idm 1;

$sql "SELECT answer FROM " QUIZ_TEXT_TABLE "
            WHERE game_id = 
$id
            AND quiz_id = 
$idm";

$resultteh $db->sql_query($sql);
while (
$row $db->sql_fetchrow($resultteh))
{
$result $row['answer'];
}
//echo $answer;

$total $userdata['user_quiz_right'] + $userdata['user_quiz_wrong'];

if (
$total < ($board_config['questions_quiz'] - 1))
{
$check_for_match strcmp($ua$result);
if(
$check_for_match == 0)
{
$correct 'UPDATE ' USERS_TABLE '
           SET user_quiz_right = user_quiz_right + 1 
           WHERE user_id = '
.$userdata['user_id'].'';
$result1 $db->sql_query($correct);

header("Location: http://www.cricketmx.com/testforum/viewquestions." $phpEx "?viewquiz=" $id "&page=" $next "");
}
//echo $result;
//echo $ua;
if($check_for_match == 1)
{
$incorrect "UPDATE " USERS_TABLE "
           SET user_quiz_wrong = user_quiz_wrong + 1 
           WHERE user_id = " 
$userdata['user_id'] . "";
$result2 $db->sql_query($incorrect);

header("Location: http://www.cricketmx.com/testforum/viewquestions." $phpEx "?viewquiz=" $id "&page=" $next "");
}
}

if(
$total 4)
{
         if(
$answer == $ua)
         {
         
$plus $userdata['user_quiz_right'] + 1;
         
message_die(GENERAL_MESSAGE'You have ' $plus' correct answers and ' $userdata['user_quiz_wrong'] .' incorrect answers!');
                 if(
$plus == $board_config['questions_quiz'])
                 {
                 
message_die(GENERAL_MESSAGE'You scored 100%! ' $board_config['questions_quiz'] . ' out of ' $board_config['questions_quiz'] . '! Well done ' $userdata['username'] . '!');
                 }
        }
         
         if (
$answer != $ua)
         {
         
$minus $userdata['user_quiz_wrong'] + 1;
         
message_die(GENERAL_MESSAGE'You have ' $userdata['user_quiz_right'] . ' correct answers and ' $minus .' incorrect answers!');
         }
}
?>