Re: [PHP] Count number of rows in table.

2002-08-25 Thread Tony Harrison
And do I need to use any other functions like mysql_fetch_row() ? Martín marqués [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]... 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? select count(*) from

Re: [PHP] Count number of rows in table.

2002-08-25 Thread Matt
] 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

Re: [PHP] Count number of rows in table.

2002-08-25 Thread Bas Jobsen
$sql = select count(*) from table_name WHERE .; $result = mysql_query($sql) or die(mysql_error); $row = mysql_fetch_row($result); $rowCount=$row[0]; or $sql = select count(*) from table_name WHERE .; $result = mysql_query($sql) or die(mysql_error); $rowCount=mysql_result($result);

Re: [PHP] Count number of rows in table.

2002-08-25 Thread salamander
or, you should be able to simply do this, without the cost of fetching the results: $result = mysql_query(SELECT count(*) FROM table WHERE); $num_rows = mysql_num_rows($result); echo $num_rows Rows\n; $sql = select count(*) from table_name WHERE .; $result = mysql_query($sql) or

Re: [PHP] Count number of rows in table.

2002-08-25 Thread Jason Wong
On Sunday 25 August 2002 22:07, salamander wrote: or, you should be able to simply do this, without the cost of fetching the results: $result = mysql_query(SELECT count(*) FROM table WHERE); $num_rows = mysql_num_rows($result); echo $num_rows Rows\n; No. This only returns 1 row regardless.

Re: [PHP] Count number of rows in table.

2002-08-25 Thread salamander
okay, so then a select * and then a num_rows ... On Sunday, August 25, 2002, at 10:11 AM, Jason Wong wrote: On Sunday 25 August 2002 22:07, salamander wrote: or, you should be able to simply do this, without the cost of fetching the results: $result = mysql_query(SELECT count(*) FROM table

Re: [PHP] Count number of rows in table.

2002-08-25 Thread Chris Shiflett
I think you were on the right track with your first response. Selecting a count(*) gives you the number of rows returned without the overhead of actually returning all of the rows to PHP. Most people will rename the count as something more easy to reference (and/or more descriptive) in the