Jump to content


Photo

select specific record from recordset


  • Please log in to reply
4 replies to this topic

#1 john_6767

john_6767
  • Members
  • PipPipPip
  • Advanced Member
  • 99 posts

Posted 26 May 2006 - 04:07 AM

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

#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 26 May 2006 - 04:55 AM

I can't understand you. Can't you just create a Previous and Next based on the current (Previous = ID-1 | Next = ID+1)?
~ D Kuang

#3 john_6767

john_6767
  • Members
  • PipPipPip
  • Advanced Member
  • 99 posts

Posted 26 May 2006 - 05:08 AM

[!--quoteo(post=377219:date=May 26 2006, 02:55 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ May 26 2006, 02:55 PM) View Post[/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

#4 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 26 May 2006 - 05:20 AM

Oh that's true. In this case:
// Previous:
SELECT id FROM `table` WHERE id < CURRENT LIMIT 1
// Next:
SELECT id FROM `table` WHERE id > CURRENT LIMIT 1
Should work.
~ D Kuang

#5 john_6767

john_6767
  • Members
  • PipPipPip
  • Advanced Member
  • 99 posts

Posted 31 May 2006 - 01:03 AM

[!--quoteo(post=377227:date=May 26 2006, 03:20 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ May 26 2006, 03:20 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Oh that's true. In this case:
// Previous:
SELECT id FROM `table` WHERE id < CURRENT LIMIT 1
// Next:
SELECT id FROM `table` WHERE id > CURRENT LIMIT 1
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,




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users