hi, im having a problem with this section of code.
Ive done it so that it will pull out the results for various modules, and display the scores, and also say pass, fail, not taken etc.
Mod1 is displaying fine, but for mod 7 its saying failed, even tho there is no record, and it should say Not Taken.
Both mod 2 and mod 7 percent will not display too. and i am outputting the same was as with mod1.
<?php echo $percent2; ?> etc
heres my code, much appriate any help.
$mod1_query = "SELECT percent, date FROM burnleycollege_mod1_results WHERE candidate_username = '".$_SESSION['username']."' ORDER BY percent DESC LIMIT 1";
$run_mod1_query = mysql_query($mod1_query);
$mod1_result = mysql_fetch_array($run_mod1_query);
$taken1 = mysql_num_rows($run_mod1_query);
$percent1 = $mod1_result['percent'];
$date1 = $mod1_result['date'];
if ($taken1 = 0)
{
$result1 = "Not Taken";
}
elseif ($percent1 > 74)
{
$result1 = '<font color="green">Passed</font>';
}
elseif ($percent1 < 75)
{
$result1 = '<font color="red">Failed</font>';
}
//========= MOD 2 =============================================================
$mod2_query = "SELECT percent, date FROM burnleycollege_mod2_results WHERE candidate_username = '".$_SESSION['username']."' ORDER BY percent DESC LIMIT 1";
$run_mod2_query = mysql_query($mod2_query);
$mod2_result = mysql_fetch_array($run_mod2_query);
$taken2 = mysql_fetch_row($run_mod2_query);
$percent2 = $mod2_result['percent'];
$date2 = $mod2_result['date'];
if ($percent2 > 74)
{
$result2 = '<font color="green">Passed</font>';
}
if ($percent2 < 75)
{
$result2 = '<font color="red">Failed</font>';
}
else
{
$result2 = "Not Taken";
}
//========= MOD 7 =============================================================
$mod7_query = "SELECT percent, date FROM burnleycollege_mod7_results WHERE candidate_username = '".$_SESSION['username']."' ORDER BY percent DESC LIMIT 1";
$run_mod7_query = mysql_query($mod7_query);
$mod7_result = mysql_fetch_array($run_mod7_query);
$taken7 = mysql_fetch_row($run_mod7_query);
$percent7 = $mod7_result['percent'];
$date7 = $mod7_result['date'];
if ($percent7 > 74)
{
$result7 = '<font color="green">Passed</font>';
}
if ($percent7 < 75)
{
$result7 = '<font color="red">Failed</font>';
}
else
{
$result7 = "Not Taken";
}
Its meant to get the highest which i think its doing.
Mod 1 is passed, and mod 2 is failed, and mod 7 is not yet taken, for the purpose of testing.