SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Apr 2004
    Location
    Wasteland
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    show images with next and previous button

    hi there,
    I have a mysql db with a table containing the following fields: ID, Name, Image

    I want to create a small script with a previous and next button.

    example:


    ImageShow

    -----------
    | Image |
    | |
    -----------

    <<previous next>>


    any ideas?

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Something like....
    PHP Code:
    # assuming connection
    $query = mysql_query("select ID, Name, Image from tableName");
    $rows = mysql_fetch_assoc($query);
    $next = $row['ID'] +1;
    ?>

    <img src="<? echo $row['Image']; ?>">
    <a href="javascript:history.back()"><<previous</a> || <a href="<? echo $next?>">next>> </a>
    On the fly so not tested!

    You can then use mysql_num_rows to find the last image and lose the next link.

    S
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Member
    Join Date
    Apr 2004
    Location
    Wasteland
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you so far...

    the problem is: it will be possibil to add and delete photos via a cms. so ID+1 won't work.

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    aaah in that case you will need to put all the id's into an array and use that along with the next(), prev() array funtions for your links.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


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
  •