note 90331 deleted from function.mysql-num-rows by danbrown

From: Date: Thu, 16 Apr 2009 17:58:45 +0000
Subject: note 90331 deleted from function.mysql-num-rows by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-153398@lists.php.net to get a copy of this message
Note Submitter: e dot nikoloff at gmail dot com ---- To lucky8919 at gmail dot com: The query you are using is wrong if you want to just get the number of rows in a table. If you want to just count the number of rows, you must use sql's count() function. This way the database returns the result much faster, depending on the table structure, but it will always be faster. Also, you don't need to ceil() or anything, cause mysql_num_rows() returns an integer. I'd use this: <?php $total_pages = mysql_num_rows(mysql_query("SELECT COUNT(*) FROM users WHERE class= '2'")); ?>

« previous php.notes (#153398) next »