[RESOLVED] Slideshow Help
Results 1 to 7 of 7

Thread: [RESOLVED] Slideshow Help

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    3

    resolved [RESOLVED] Slideshow Help

    Hi

    I use a simple slideshow script called Micro Photo Slideshow I found for my website. It works very well but there is one problem, it shows the photos in a random order ( I have named the files sequentially).
    http://www.secalis.co.uk/ssi/ssi.php
    Could some kind member point me in the right direction so that the photos are shown in order?
    I can write simple PHP ,but not database scripts. Here is the script I use
    /************* S E T T H I S V A R I A B L E S ****************************/
    $timer = 4; // Switch to the next image after 5 sec
    $title = "Micro Photo Slideshow"; // Title of your photo album
    /******************************************************************************/


    function displayPhoto(){
    global $gid;
    $id = isset($_GET['id']) ? $_GET['id'] : 0;
    $actFile = 0;

    // Open the actual directory
    if ($handle = opendir(".")) {
    // Read all file from the actual directory
    while ($file = readdir($handle)) {
    // Check whether tha actual item is a valid file
    if (is_file($file)){
    // Check whether the actual image is a thumbnail
    if ((strpos($file,'.jpg')) || (strpos($file,'.jpeg'))){
    if ($actFile == $id){
    return '<img src="'.$file.'" class = "image" alt="Slideshow" />';
    }
    if ($actFile == 0){
    $first = '<img src="'.$file.'" class = "image" alt="Slideshow" />';
    }
    $actFile++;
    }
    }
    }
    }
    $gid = 1;
    return $first;
    }

    $gid = isset($_GET['id']) ? $_GET['id'] : 0;
    $gid++;

    $image = displayPhoto();

    $url = $_SERVER['PHP_SELF'].'?id='.$gid;

    ?>
    TIA

    Brian

  2. #2
    Junior Member
    Join Date
    Jan 2013
    Posts
    17
    You want to use sort() to sort the files after you open up the directory.
    I would read up on tutorials on how to display, and write to, files and directories.

    I use both display and write to files and dirs, to include function modules for my software based on the the licence key.

    And remember echo and print_r are you friends to see what is going on in the background while you are programming.

  3. #3
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,876
    In getting something that sort can be used on, scandir would be more convenient than the opendir/readdir/closedir loop.
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  4. #4
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,420
    Even better: glob() is a little more concise, especially given that you could do something like:

    PHP Code:
    glob('*.{jpg,jpeg}'GLOB_BRACE
    to take care of the filename filtering for you.

  5. #5
    Junior Member
    Join Date
    Jan 2013
    Posts
    3
    Thanks for the replies, they are exactly what I need.
    By the way, how do you add the PHP code box to the message?

    Brian

  6. #6
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,420
    Quote Originally Posted by bripriuk View Post
    Thanks for the replies, they are exactly what I need.
    Does this mean you've resolved the problem? If so, don't forget to mark this thread resolved using the link on the Thread Tools menu above.

    Quote Originally Posted by bripriuk View Post
    By the way, how do you add the PHP code box to the message?
    You can either manually type out the [php]..[/php] bbcode tags, or you can use the PHP code icon on the advance editor page (last icon in the second row).

  7. #7
    Junior Member
    Join Date
    Jan 2013
    Posts
    3
    Many thanks for the help, I used the glob option suggested by Brad.

    Brian

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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