How would you detect how many rows are in a MySQL table which meet a certain criteria:
Pseudo Code:
$rowCount=How Many Rows in Table WHERE published='yes';
Thanks
| SitePoint Sponsor |
How would you detect how many rows are in a MySQL table which meet a certain criteria:
Pseudo Code:
$rowCount=How Many Rows in Table WHERE published='yes';
Thanks
PHP Code:<?php
$sSQL = "SELECT COUNT(id) AS numRows FROM table WHERE foo = 'bar'";
$rQuery = mysql_query($sSQL);
$aResult = mysql_fetch_assoc($rQuery);
printf(
'The query "%s" resulted in %s rows.',
$sSQL,
$aResult['numRows']
);
?>
@AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.
Bookmarks