Re: Re: Listing A Certain # Range

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/
---------------------------------------------------------------------------

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux