note 90331 added to function.mysql-num-rows

From: Date: Thu, 16 Apr 2009 17:11:00 +0000
Subject: note 90331 added to function.mysql-num-rows
Groups: php.notes 
Request: Send a blank email to php-notes+get-153397@lists.php.net to get a copy of this message
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'")); ?> ---- Server IP: 89.190.194.18 Probable Submitter: 77.78.9.87 ---- Manual Page -- http://www.php.net/manual/en/function.mysql-num-rows.php Edit -- https://master.php.net/note/edit/90331 Del: integrated -- https://master.php.net/note/delete/90331/integrated Del: useless -- https://master.php.net/note/delete/90331/useless Del: bad code -- https://master.php.net/note/delete/90331/bad+code Del: spam -- https://master.php.net/note/delete/90331/spam Del: non-english -- https://master.php.net/note/delete/90331/non-english Del: in docs -- https://master.php.net/note/delete/90331/in+docs Del: other reasons-- https://master.php.net/note/delete/90331 Reject -- https://master.php.net/note/reject/90331 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#153397) next »