Re: Number of Rows in a MySQL table
| From: | Philip Olson | Date: | Thu, 28 Dec 2000 20:44:45 +0000 |
| Subject: | Re: Number of Rows in a MySQL table | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-32147@lists.php.net to get a copy of this message | ||
Try :
function getRowCount ($db_table,$db_column='',$db_value='')
{
$q = "select count(*) from $db_table";
if (!empty($db_column)) {
$q .= " WHERE $db_column='$db_value'";
}
$r = mysql_query ("$q");
Return mysql_result($r,0);
}
getRowCount('table');
A little more explanation can be found in user comments :
PHP Manual : mysql_num_rows
http://www.php.net/manual/function.mysql-num-rows.php
Philip
On Thu, 28 Dec 2000, Ben Wiechman wrote:
> I can't seem to dig this up, is there a simple way to find out the total
> number of rows in a table w/o selecting all the rows and counting the number
> of rows returned? I can't seem to find an example of how to do this.
>
> Ben
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>