mySQL Workbench gives different results than my webpage

All emails that my website sends out are stored in the notifications table. Every half hour up to 500 at a time will be emailed out. Here is the query I’m using:

select priority, type, count(*) as total from notifications where sent is null group by type order by priority;

The results indicate there are 37 “Matched from Search” type emails AND 2 “Stop Alerts” type emails waiting to be sent out. Here is my php code that I’m using on my Admin Tools webpage so I can easily see what is waiting to go out from the notifications table:


$emailsWaiting = "select priority, type, count(*) as total from notifications where sent is null group by type order by priority";

$results = mysql_query ($emailsWaiting) OR die(mysql_error());
$row = mysql_fetch_assoc($results);

if ($row = mysql_fetch_array($results)) {

print ("<br><br>");

print ("<TABLE align='center' cellpadding='3' cellspacing='3' WIDTH='50%' border='1'>");

print ("<TR>");
print ("<TH>Priority</TH>");
print ("<TH>Type</TH>");
print ("<TH>Waiting</TH>");
print ("</TR>");


do {

$priority  = $row["priority"];
$type	     = $row["type"];
$total      = $row["total"];


$totalCount = $totalCount + $total;

print ("<TR>");
print ("<TD align='center'>$priority</TD>");
print ("<TD align='center'>$type</TD>");
print ("<TD align='center'>$total</TD>");
print ("</TR>");

} while ($row = mysql_fetch_array($results));

print ("<TR>");
print ("<TD colspan='3' align='center'>Total Emails: $totalCount</TD>");
print("</TR>");

print ("</Table>");
print ("</form>");

} else {

print ("<br><p>There are no emails waiting to go out.</p>");
}

When I view this webpage it indicates that there are 2 “Stop Alerts” emails waiting to go out, BUT that is all. Why aren’t the 37 “Matched from Search” type emails showing up? So in summary, I’m confused why running the query in mySQL WorkBench shows one set of results, while my webpage is showing something different.

Thank you.

You might want to just switch to a regular while and do the if check on mysql_num_rows … but that shouldnt really have an effect on the output so far as i can see…

is mySQL Workbench connecting to the database you’re running this query on, or a local copy?

What do you mean a “regular while” ? Do you have any other thoughts?