I am trying to calculate the total worth of lecture courses that an individual has taken. They must attend (cle_signup.attended=’x’) and the course must have a credit worth (cle.accredited=’Yes’).
There are 3 levels of individuals: “1st or 2nd year”, “3rd or above” and “other”.
Each level had a different value showing:
[INDENT]1st or 2nd year = “newmember” value
3rd or above = “cpd & eppm” value
other = no value[/INDENT]
If I remove the if statement, my sum works but I dont get the correct value because I dont have any criteria.
My if statements give no results and no errors.
[code=php]$query = “SELECT SUM(cle.newmember), SUM(cle.cpd), SUM(cle.eppm) FROM cle, cle_signup WHERE cle_signup.attended=’x’ AND cle.accredited=’Yes’ AND (cle_signup.fname like ‘%$trimmed%’ OR cle_signup.lname like ‘%$trimmed%’)”;
$result = mysql_query($query) or die(“Couldn’t execute query: “.mysql_error());
while($rows = mysql_fetch_array($result)){
$year=$rows[‘cle_signup.year’];
if ($year == “1st or 2nd year”)
{
echo “Accredited Total = “.$rows[‘SUM(cle.newmember)’].””;
}
elseif ($year == “3rd or above”)
{
echo “Accredited CPD Total = “.$rows[‘SUM(cle.cpd)’].” & Accredited EPPM Total = “.$rows[‘SUM(cle.eppm)’].””;
}
else
{
echo “”;
}
}