Hello Again.
It might help if you know what I'm trying to do here, please excuse my lag of talent to explain.
I'm trying to make a score system where the user can achieve a league based on the score he has.
There is 15 different tests, each test have 18 level difficulties, you have to complete a test to obtain a level.
if you test score is 0 you will start out with beginner league.
If you obtain a level 1 in a test you will become Silver League.
If you obtain a level 3 in 3 different test you will become Gold League.
If you obtain a level 5 in 5 different test you will become Diamond League.
If you obtain a level 7 in 7 different test you will become master League.
Now I made a database table where I will have a row with user_id, test_1, test_2, test_3.... test_15. I will then update the score in each column so if the user have a score of level 3 in 3 or more test he will become gold league.
Now we move on to the code thats the hard part.
// Check Each test level and count them
function count_league_score($email){
$email = mysql_real_escape_string($email);
$um = $_SESSION['email'];
$sql = "SELECT test_1, test_2, test_3, test_4, test_5, test_6, test_7, test_8, test_9, test_10, test_11, test_12, test_13, test_14, test_15
FROM
level_and_league INNER JOIN users
ON level_and_league.user_id = users.user_id
WHERE `user_email` = '{$um}'";
$result = mysql_query($sql);
if (!$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "No rows found, nothing to print so am exiting";
exit;
}
$test_score = mysql_fetch_assoc($result);
return $test_score;
if ($test_score >= 7 ) // Require a count of 7 or more of the level 7
{ $league_cal = "Master League";}
elseif ($test_score >= 5 ) // Require a count of 5 or more of the level 5
{ $league_cal = "Diamond League";}
elseif ($test_score >= 3 ) // Require a count of 3 or more of the level 3
{ $league_cal = "Gold League";}
elseif ($test_score >= 1) // Require a count of 1 or more of the level 1
{ $league_cal = "Silver League";}
elseif ($test_score <= 0 and $test_score > -100 ) // Require a count of 0 or more of the level 0
{ $league_cal = "Beginner League";}
else echo mysql_error ();
return($league_cal);
If you have a code that works please do let me know.
best regards
Wizzuriz