Re: Re: Listing A Certain # Range

From: Date: Tue, 17 Dec 2002 06:51:17 +0000
Subject: Re: Re: Listing A Certain # Range
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-24209@lists.php.net to get a copy of this message
On Tue, 17 Dec 2002, conbud wrote: > Conbud wrote: > > Hello, > > Im using MySQL and PHP 4.2.3 on Apache and Mandrake Linux, I was > > wondering how to get PHP to list let says row 5 - 10 from a database, I > > read the MySQL manual and all I could find is LIMIT 0,5 to list just the > > first 5, but I dont know how to make that list 5 - 10 or 10 - 15. Any > > help would be appreciated. > > Hey, Is there another way to do it with out using Limit ? Sure, select all of the lines, pass a var offset, then loop through the results. for ($i=0;$i<mysql_num_rows($result);$i++) { if ($j>=$number_to_display) break; if ($i<=$offset) continue; print "stuff here"; } Terrible code, I know, but you should be able to get the idea. Why wouldn't you use limit? That seems silly. I know Holmes would agree. :-) Peter --------------------------------------------------------------------------- Peter Beckman Internet Guy beckman@purplecow.com http://www.purplecow.com/ ---------------------------------------------------------------------------

« previous php.db (#24209) next »