RE: [PHP-DB] How to find out the number of rows in a table?

2002-01-24 Thread Sam Masiello


Try the following:

$sql = "select count(*) as c from your_table" ;
$result = mysql_query(your_db, $sql, your_connection_identifier) ;
$row_count = mysql_result($result, 0, 'c') ;

Now $row_count contains the number of rows in your table named "your_table"

HTH

--Sam Masiello


"Andy" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi there,
>
> I am trying to find out the number of rows in a table. The mysql docu says
> there is a mysql_num_rows statement but it requiers a sql statement in
> front. How could I do this more efficiently? Can anybody make an example,
> please? I am sure that there is an more easy way.
>
> Cheers Andy
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] How to find out the number of rows in a table?

2002-01-24 Thread Rick Emery

SELECT count(*) AS ctr FROM mytable;

-Original Message-
From: Andy [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 24, 2002 10:36 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] How to find out the number of rows in a table?


Hi there,

I am trying to find out the number of rows in a table. The mysql docu says
there is a mysql_num_rows statement but it requiers a sql statement in
front. How could I do this more efficiently? Can anybody make an example,
please? I am sure that there is an more easy way.

Cheers Andy



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]