Jump to content

Archived

This topic is now archived and is closed to further replies.

john_6767

select specific record from recordset

Recommended Posts

hey,
just started using php and was wondering how i can select a specific record from a recordset (i used to do this in asp). To put you in the picture i have a photo gallery which is a page that diplsays a whole heap of thumbnails form a db, i have another page that loads when a thumbnail is clicked and shows the full version of the image. i want to get this page with the full image to have a previous and next image button which is where i come unstuck.. at the moment both page recordsets are just sorted by imageID and so the previous/next work on the large image page but i can't get the page to show the image from the page before..(it just shows the first imageID, i have a repeat region on the page set to 1..) i assume there is a standard way to do this and its pretty easy? Am i going about this the wrong way?
thanks in advance..
-John

Share this post


Link to post
Share on other sites
I can't understand you. Can't you just create a Previous and Next based on the current (Previous = ID-1 | Next = ID+1)?

Share this post


Link to post
Share on other sites
[!--quoteo(post=377219:date=May 26 2006, 02:55 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ May 26 2006, 02:55 PM) [snapback]377219[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I can't understand you. Can't you just create a Previous and Next based on the current (Previous = ID-1 | Next = ID+1)?
[/quote]
I don;t think that will work as the id's aren't guaranteed to be consecutive numbers.. its from a db (so if i have ID's 1 2 3 4 and then i delete ID 3 i have the ID's 1 2 4 in which case when i click next on ID 2 i would get an error, yes?).
Please correct me if i am wrong, i am sure there has to be an easy way to do this i'm just not seeing it..
cheers

Share this post


Link to post
Share on other sites
Oh that's true. In this case:
[code]// Previous:
SELECT id FROM `table` WHERE id < CURRENT LIMIT 1
// Next:
SELECT id FROM `table` WHERE id > CURRENT LIMIT 1[/code]
Should work.

Share this post


Link to post
Share on other sites
[!--quoteo(post=377227:date=May 26 2006, 03:20 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ May 26 2006, 03:20 PM) [snapback]377227[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Oh that's true. In this case:
[code]// Previous:
SELECT id FROM `table` WHERE id < CURRENT LIMIT 1
// Next:
SELECT id FROM `table` WHERE id > CURRENT LIMIT 1[/code]
Should work.
[/quote]
cheers, i get the idea, but i have been using dreamweaver to create my sql statements, could you please let me know how i would put this on a page., i.e. what goes before and at end of this statement in the php tags. I am a complete newbie.. but i should catch its just i've never done sql statements in php before.. thanks for your advice,

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.