Jump to content

[SOLVED] Slideshow?


JP128

Recommended Posts

A slide show can not be done with php on it own you would need the page to refresh so meny times it would be madness what you need to do is use javascript or ajax to get a proper slide show in place or you could use flash.

flash seems to look the best and used via ebay

heres a link to help you ok.
http://www.javascriptkit.com/script/script2/jsslide.shtml
Link to comment
https://forums.phpfreaks.com/topic/31670-solved-slideshow/#findComment-146817
Share on other sites

You can do something like this:

[code]<?php

$images_dir = "/image-dir-here/";
$image_formats = array("jpg", "jpeg", "gif", "png"); //formats of pictures in the folder


$files = scandir($images_dir);
$i = 0;
$images = array();
foreach($files as $key => $filename)
{
if(in_array(strtolower(substr(strrchr($filename,"."),1)), $image_formats))
{
$images[$i] = $filename;
$i++;
}
}

$num_pics = $i-1;
if($num_pics == -1)
die("No pics in folder");

if(isset($_GET['id']) && is_numeric($_GET['id']) && $_GET['id'] <= $num_pics && $_GET['id'] >= 0)
$id = $_GET['id'];
else
$id = 0;

echo '<img src="'.$images_dir.$images[$id].'"><br>';
if($id > 0)
echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.($id-1).'">previous</a>';
echo '  ---  ';
if($id < $num_pics)
echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.($id+1).'">next</a>';

?>[/code]

Orio.
Link to comment
https://forums.phpfreaks.com/topic/31670-solved-slideshow/#findComment-146830
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.