Jump to content

Troulbe with the COUNT()


michaeln82

Recommended Posts

I'm having a heck of a time getting a row count:

 

$query2 = "SELECT COUNT(nannies.nannisBulk) AS 'myRowCount'
FROM nannies, nanniesBulk
WHERE nannies.nannyID = nanniesBulk.nannyID
$conditions_sql
$zip_sql
AND status = 2
AND visible = 1
AND removed = 0";
$result2 = mysql_query($query);

if ($row2 = mysql_fetch_array($result2)) {
 $myRowCount = $row2['myRowCount'];
 die($myRowCount);
} else {
 $rowCount = 0;
}

 

When I run this, I get no output at all. If I try "die($query2)" and then cut/paste the query directly into phpMyAdmin it outputs "5" as the number of rows. If I try "$myRowCount = $row2[0]" i get 3 (instead of 5)! WTF is going on?

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/125998-troulbe-with-the-count/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.