I have 2 tables:
[B]Table 1 – cle
id | cle | newmember | eppm
[B]Table 2 – cle_signup
id | fname | lname | cle | year
From the “cle_signup” table, I need distinct first & last names and from the “cle” table, I need the sum of “newmember” OR the sum of “eppm”.
The output is all names from the “cle_signup” table (not distinct names) and the sum is of the eppm only. What am I doing wrong?
[code=php]$query = “SELECT DISTINCT cle_signup.fname AS fname, cle_signup.lname AS lname, cle.newmember AS newmember, cle.eppm AS eppm, cle_signup.year AS year FROM cle JOIN cle_signup ON cle.cle=cle_signup.cle WHERE cle_signup.attended=’x’ ORDER BY cle_signup.lname”;
$result = mysql_query($query) or die(“Couldn’t execute query: “.mysql_error());
while ($rows=mysql_fetch_array($result)) {
$fname = $rows[‘fname’];
$lname = $rows[‘lname’];
$name = “$lname, $fname”;
$year = $rows[‘year’];
$newmember = array(newmember);
$eppm = array(eppm);
echo “<tr><td class=”search”>$name</td>”;
if ($year == “1st or 2nd year” AND $accredited == “Yes”) {
echo “<td>” . array_sum($newmember) . “</td></tr>”;
} else {
echo “<td>” . array_sum($eppm) . “</td></tr>”;
}
}