Simple slide show

Discussion in 'PHP' started by adamjblakey, Jun 27, 2007.

  1. #1
    Hi,

    Does anyone know of a simply slide show script that just have the image and then a previous and next button. Also it needs to run from a folder that i specify.

    I have looked everywhere but i cannot find one that will just work from a folder the i specify.

    Cheers,
    Adam
     
    adamjblakey, Jun 27, 2007 IP
  2. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #2
    
    <?php
    $my_folder = "my_images";
    $files = array();
    
    if ($handle = opendir($my_folder))
    {
    	while (false !== ($file = readdir($handle)))
    	{
    		if ($file != "." && $file != "..")
    			array_push($files,$file);
    	}
    	closedir($handle);
    }
    if ( isset($_GET['id']) )
    	$id = $_GET['id'];
    else
    	$id = 0;
    
    ?>
    
    <img src="<?=$my_folder."/".$files[$id];?>" alt="" /><br />
    
    <?php
    if ($id > 0)
    	echo "<p style=\"width:200px; float:left;\"><a href=\"".$_SERVER['PHP_SELF']."?id=".($id-1)."\">Previous</a></p>";
    else
    	echo "<p style=\"width:200px; float:left;\">Previous</p>";
    
    if ($id <= count($files) - 2)
    	echo "<p style=\"float:left;\"><a href=\"".$_SERVER['PHP_SELF']."?id=".($id+1)."\">Next</a></p>";
    else
    	echo "<p style=\"float:left;\">Next</p>";
    ?>
    
    PHP:
     
    ansi, Jun 27, 2007 IP
  3. abedelrahman

    abedelrahman Peon

    Messages:
    213
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    yes, wow, it works for me, saved me some cash!!
     
    abedelrahman, Jun 27, 2007 IP
  4. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #4
    you can still throw me a few bucks if you like :)
     
    ansi, Jun 27, 2007 IP
  5. adamjblakey

    adamjblakey Active Member

    Messages:
    1,121
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    80
    #5
    Very good, thanks a lot :)
     
    adamjblakey, Jun 28, 2007 IP
  6. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #6
    you're welcome. need anything else let me know. was feeling generous. not the best looking, but i just slapped it together for you.
     
    ansi, Jun 28, 2007 IP
  7. dougvcd

    dougvcd Peon

    Messages:
    267
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    how do i change this so it runs auto
    cheers
    Doug
     
    dougvcd, Sep 8, 2009 IP
  8. moronoid

    moronoid Well-Known Member

    Messages:
    70
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    111
    #8
    i will try your php code.
     
    moronoid, Sep 8, 2009 IP
  9. Lastbutnotleast

    Lastbutnotleast Peon

    Messages:
    2,612
    Likes Received:
    105
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Do you have something without PHP? Maybe javascript or a cheap and easy to use software?
     
    Lastbutnotleast, Jan 1, 2010 IP