Re: Logic question
| From: | Hugh Bothwell | Date: | Wed, 17 Apr 2002 16:08:08 +0000 |
| Subject: | Re: Logic question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-93343@lists.php.net to get a copy of this message | ||
"Mike Fifield" <Mike.Fifield@schwab.com> wrote in message
news:FFE9B7BE532CD411872F00508BDFB8FE0EB76BA1@n6010vmx.nt.schwab.com...
> 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";
// number of items to display per page
$perpage = 3;
// current page, in [1..max]
$page = (int) ($offset / $perpage);
$query =
"SELECT image_id, image_url "
."FROM galleries AS g "
."LEFT JOIN images AS i "
."USING (gallery_id) "
."WHERE g.gallery='$gallery' "
."SORT BY i.image_id DESC "
."LIMIT ".($perpage*($page-1)).", $perpage";