Re: Count number of rows in table.
| From: | Matt | Date: | Sun, 25 Aug 2002 13:05:50 +0000 |
| Subject: | Re: Count number of rows in table. | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-114047@lists.php.net to get a copy of this message | ||
>>> On Sáb 24 Ago 2002 11:19, Tony Harrison wrote:
>>> How would I count the number of rows in a mysql table with a WHERE
>>> clause?
> >
>> "Martín marqués" <martin@bugs.unl.edu.ar> wrote in message
> > news:200208241133.20121.martin@bugs.unl.edu.ar...
> > select count(*) from table_name WHERE .....
> >
>From: "Tony Harrison" <tonyh21@tharrison21.fsnet.co.uk>
> Sent: Saturday, August 24, 2002 5:54 PM
> Subject: Re: [PHP] Count number of rows in table.
>
> And do I need to use any other functions like mysql_fetch_row() ?
>
Yes. It's a regular sql statement, so you must fetch the results.
$sql = "select count(*) from table_name WHERE .....";
$result = mysql_query($sql) or die(mysql_error);
$row = mysql_fetch_row($result);
$rowCount=$row[0];