SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    May 2002
    Location
    Barcelona, Spain
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Advancing mysql pointer

    Hello all. I was wondering if anyone had an easy way to advance the mysql pointer in a query.

    This is the situation: I have a table that contains samples. I want to build a page that has a previous and next buttons. But to show one sample at a time.

    Of course I could use
    PHP Code:
    mysql_result($res$offset); 
    and increase the offset each time. But I was wondering if there was a way to do it without requering the db every time they hit next or previous.

    Thanks.
    Used to prefer PHP.
    Now I prefer Maya but stuck with PHP
    bruji.com

  2. #2
    PHP Otaku Gibb's Avatar
    Join Date
    Jul 2004
    Location
    Texas
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it seems like it what you need is to pull all the samples out of the DB and store them in an array. Then you can step through the array with your next and previous buttons without requerying the DB.

  3. #3
    SitePoint Evangelist
    Join Date
    May 2002
    Location
    Barcelona, Spain
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Gibb
    it seems like it what you need is to pull all the samples out of the DB and store them in an array. Then you can step through the array with your next and previous buttons without requerying the DB.
    Hmmm... now that you mention it, mysql_fetch_assoc() already puts them into an array right? So maybe I can just grab them from there by advancing that array. But I'm not sure if that will work since it doesn't seem to create a normal array. I'll try it.

    Thanks.
    Used to prefer PHP.
    Now I prefer Maya but stuck with PHP
    bruji.com


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •