Selecting 3 rows
Posted: Mon Mar 22, 2010 4:55 pm
I'm trying to make an image gallery, the images in the database are stored as follows:
Id|name|description|path|categoryId
When a user clicks on a thumbnail, it opens up in a new page with the normal sized picture. I want to generate the links to the next picture and previous picture below the picture. The next and the previous links should link to the next and the previous picture in only the current category. The categoryid is stored in $_SESSION['catid']. Is it possible to fetch 3 rows with one query, the first one containing the previous picture, the second containing the current and the third containing the next picture.
For example if I have the table:
1|Etc1|description1|path1|1
2|Etc2|description2|path2|3
3|Etc3|description3|path3|5
4|Etc4|description4|path4|3
5|Etc5|description5|path5|2
6|Etc6|description6|path6|4
7|Etc7|description7|path7|3
8|Etc8|description8|path8|1
it would grab the rows in bold, when I have the current picture id which is 4 and the categoryid which is 3.
Thanks a bunch.
Id|name|description|path|categoryId
When a user clicks on a thumbnail, it opens up in a new page with the normal sized picture. I want to generate the links to the next picture and previous picture below the picture. The next and the previous links should link to the next and the previous picture in only the current category. The categoryid is stored in $_SESSION['catid']. Is it possible to fetch 3 rows with one query, the first one containing the previous picture, the second containing the current and the third containing the next picture.
For example if I have the table:
1|Etc1|description1|path1|1
2|Etc2|description2|path2|3
3|Etc3|description3|path3|5
4|Etc4|description4|path4|3
5|Etc5|description5|path5|2
6|Etc6|description6|path6|4
7|Etc7|description7|path7|3
8|Etc8|description8|path8|1
it would grab the rows in bold, when I have the current picture id which is 4 and the categoryid which is 3.
Thanks a bunch.