Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2003
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    creating a txt gallery using includes

    I'm trying to create a gallery of txt files on my website. I've just recently learned about server side includes and how to use them to post the contents of files inside of webpages. What I'm wondering is if anybody knows how I could make a slide show of the files, operated by "back" and "next" links, without hardcoding the filenames to the webpage. I was thinking along the lines of having a numerically-ordered directory of txt files (001, 002, 003, etc). The "next" link would lead you to the next file in the directory . . . "back" would take you backward numerically. An example of what I'm looking for can be found on this page:

    http://dreamflower.freezope.org/prose

    How is this kind of thing done?


    -Max

  • #2
    me'
    me' is offline
    Senior Coder
    Join Date
    Nov 2002
    Location
    Warwickshire, England
    Posts
    1,229
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Should be possible by passing a numerical parameter in the URL, and using this to include the text file, then for the 'next' or 'previous' links, reading off this parameter and incrementing or decrementing it.
    David House - Perfect is achieved, not when there is nothing left to add, but when there is nothing left to take away. (Antoine de St. Exupery).
    W3Schools | XHTML Validator | CSS Validator | Colours | Typography | HTML&CSS FAQ | Go get Mozilla Now | I blog!

  • #3
    New Coder
    Join Date
    Mar 2003
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Current URL /script.php?id=5

    Code:
    <?
    
    $max = 10; // The highest file number
    $min = 0; // The lowest file number
    
    if ($id == $min) 
        $prev = $max; // Sets $prev to $max since there's nothihng below $min
    else
        $prev = $id - 1; // makes $prev = 4
    
    if ($id == $max)
        $next = $min; // Sets $next to $min since there's nothing above $max
    else
        $next = $id + 1; // makes $next = 6
    
    include ("$id.txt");
    
    ?>
    
    <a href="/script.php?id=$prev">Prev</a>|<a href="/script.php?id=$next">Next</a>


  •  

    Posting Permissions

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