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

From: Date: Tue, 26 Jan 2010 22:31:41 +0000
Subject: note 95872 deleted from function.mysql-num-rows by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-165342@lists.php.net to get a copy of this message
Note Submitter: Michel Schenk ---- A little combination of previous solutions, I only needed to know how many rows and I have to limit a sorted list: <?PHP //connect to dbase $qry = "SELECT SQL_CALC_FOUND_ROWS '0' FROM $table LIMIT 0 UNION SELECT FOUND_ROWS()"; $result=mysql_query($qry) or die(mysql_error()); while ($row = mysql_fetch_row($result)) $total_rows = $row[0]; ?> After this code you can do SELECT ... FROM ... ORDER BY ... LIMIT ... I've tried to do this in one query with UNION like: (SELECT SQL_CALC_FOUND_ROWS '0'... FROM ... ORDER BY ... LIMIT ...) UNION (SELECT FOUND_ROWS() ...) This didn't work :-( maybe somebody can solve this?

« previous php.notes (#165342) next »