PHP, MYSQL, CSS, LINUX TUTORIALS

MySql rows count

There are two ways that i used to view the MySql number of rows.

The first method is to use the php function: mysql_num_rows()

$rows = mysql_num_rows(mysql_query('SELECT id FROM accounts'));
echo $rows;

The second method is to use the mysql function: count() which is faster

$rows = mysql_fetch_row(mysql_query('SELECT count(id) FROM accounts'));
echo $rows[0];

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>