Re: Logic question

From: Date: Wed, 17 Apr 2002 16:13:06 +0000
Subject: Re: Logic question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-93345@lists.php.net to get a copy of this message
You could try something like this. I think my syntax is correct for what you're attempting to do.. if (isset($start_row)) { if (isset($next)) {$start_row += 3;} if (isset($prev)){$start_row -= 3;} } else { $start_row = 0; } $query = "SELECT * FROM images WHERE gallery_id = $gallery_id ORDER BY imageid LIMIT $start_row,3"; // The important thing here is (LIMIT a,b) where a is the starting row and b is how many rows you want to retrieve. ----- Original Message ----- From: "Fifield, Mike" <Mike.Fifield@schwab.com> To: <php-general@lists.php.net> Sent: Wednesday, April 17, 2002 9:43 AM Subject: [PHP] Logic question > I am running the following SQL query which is returning a list of about 100 > entries. The entries are sorted numerically by image_id, but the numbers in > image_id are not sequential. For example a return might look like this. > 97 > 54 > 53 > 43 > 32 > 31 > 21 > > $query = "select * from galleries, images where galleries.gallery = > '$gallery' and images.gallery_id = galleries.gallery_id and images.image_id > >= $offset - 3 and images.image_id < $offset order by images.image_id desc"; > > > What I am trying to do is print out the first 3 rows on one page, and when > the visitor hits next I want to be able to display the next 3, and so on. > Does anyone have any ideas on how to do this? > > Mike Fifield > Charles Schwab & Co, Inc. > WARNING: All e-mail sent to or from this address will be received by the > Charles Schwab corporate e-mail system and is subject to archival and review > by someone other than the recipient. > >

« previous php.general (#93345) next »