hi. i'm displaying users' names in an html table ordered by the number of evaluations they have submited. my table displays: user id, number of evals, and date of last eval. all users' id's are in a table called 'users'; however, only users who have submitted evaluations have their id's in the evaluations table. i can succesfully count and order the id's from the evaluations table, but i want the id's that are abscent from the 'evaluations' table (but present in 'users' table) to display with a count equal to 0. i can't figure out how to join the two tables without screwing up the count. thanks. --brian
//get the users' id (a_id), respective number of evals and date of last eval from evaluations table; order them in descending order by number of evaluations.
$result = mysql_query("SELECT a_id, COUNT(eval_id) as eval_num, MAX(date) AS last_eval FROM evaluations GROUP BY a_id ORDER BY eval_num DESC",$db);
if ($myrow = mysql_fetch_array($result)){
//start html table
echo "<table border=1>\n";
echo "<tr><td><font color=\"003399\" size=\"2\" face=\"Arial, Helvetica, sans-serif\"><strong>Attending</strong></font></td>";
echo "<td><font color=\"003399\" size=\"2\" face=\"Arial, Helvetica, sans-serif\"><strong>Evals</strong></font></td>";
echo "<td><font color=\"003399\" size=\"2\" face=\"Arial, Helvetica, sans-serif\"><strong>Last Eval</strong></font></td>";
do {
//output to html table
printf("<tr><td><font color=\"003399\" size=\"2\" face=\"Arial, Helvetica, sans-serif\">%s</font></td>", $myrow["a_id"]);
printf("<td><font color=\"003399\" size=\"2\" face=\"Arial, Helvetica, sans-serif\">%s</font></td>", $myrow["eval_num"]);
printf("<td><font color=\"003399\" size=\"2\" face=\"Arial, Helvetica, sans-serif\">%s</font></td>", $myrow["last_eval"]);
} while ($myrow = mysql_fetch_array($result));
//end table
echo "</tr></table>\n";
}