Jump to content

Slideshow


claffin

Recommended Posts

Im trying to create a slideshow for my gallery i have the following code

 

config.php

<?
$total = 4; //Total number of images in slideshow
$var_total = 5; //Total number of images + 1

$arr_img = Array();
$handle = opendir('../gallery/');
while (false !== ($file = readdir($handle))) {
if ($file != "." & & $file != "..") {
$arr_img[] = $file;
}
}

$i = 1;
$next = 2;
$back = 0;
while($i <= $total){
if($back == 0) {
$back_link = $total;
} else {
$back_link = $back;
}
if($next == $var_total) {
$next_link = 1;
} else {
$next_link = $next;
}
if ($image == "$i") {
$next_img = "$next_link";
$back_img = "$back_link";
}
$i++;
$next++;
$back++;
}?> 

 

and in gallery.php I have

 

<?
require_once "config.php";
if($_REQUEST[auto] == "on") {
$meta = "<meta http-equiv="refresh" content="2;url=$PHP_SELF?image=$next_img&auto=on" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />";
$nav = "<a href="$PHP_SELF?image=$back_img&auto=on">Back</a> |
<a href="$PHP_SELF?image=$image&auto=off">Stop Slideshow</a> |
<a href="$PHP_SELF?image=$next_img&auto=on">Next</a>";
}
if($_REQUEST[auto] == "off" || !$_REQUEST[auto]) {
$meta = " <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />";
$nav = "<a href="$PHP_SELF?image=$back_img&auto=off">Back</a> |
<a href="$PHP_SELF?image=$image&auto=on">Start Slideshow</a> |
<a href="$PHP_SELF?image=$next_img&auto=off">Next</a>";
}
if(!$_REQUEST[image]) { //Default thumbnil page
$i = 0;
foreach($arr_img as $var_img) { //Grabs all the image names in th array
if($var_img != "") { //Dont show first entery of the array that is blank
echo<<<EOF
<a href="$PHP_SELF?image=$i"><img src="../gallery/$var_img" /></a>
EOF;
}
$i++;
}
} else { //Show the slides
echo<<<EOF
<div align="center">
<img src="./gallery/$arr_img[$image]" /><br /><br />
$nav
</div>
EOF;
}
?> 

 

I found this code online as I am unsure of how to do a slideshow

 

the results can be found at http://handweaving.seitservices.com.au/index.php?p=gallery

Link to comment
https://forums.phpfreaks.com/topic/149733-slideshow/
Share on other sites

got rid of all the " and replaced with '

 

<?
require_once 'config.php';
if($_REQUEST[auto] == 'on') {
$meta = '<meta http-equiv='refresh' content='2;url=$PHP_SELF?image=$next_img&auto=on' />
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />';
$nav = '<a href='$PHP_SELF?image=$back_img&auto=on'>Back</a> |
<a href='$PHP_SELF?image=$image&auto=off'>Stop Slideshow</a> |
<a href='$PHP_SELF?image=$next_img&auto=on'>Next</a>";
}
if($_REQUEST[auto] == 'off' || !$_REQUEST[auto]) {
$meta = ' <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />';
$nav = '<a href='$PHP_SELF?image=$back_img&auto=off'>Back</a> |
<a href='$PHP_SELF?image=$image&auto=on'>Start Slideshow</a> |
<a href='$PHP_SELF?image=$next_img&auto=off'>Next</a>';
}
if(!$_REQUEST[image]) { //Default thumbnil page
$i = 0;
foreach($arr_img as $var_img) { //Grabs all the image names in th array
if($var_img != '') { //Dont show first entery of the array that is blank
echo<<<EOF
<a href='$PHP_SELF?image=$i'><img src='../gallery/$var_img' /></a>
EOF;
}
$i++;
}
} else { //Show the slides
echo<<<EOF
<div align='center'>
<img src='./gallery/$arr_img[$image]' /><br /><br />
$nav
</div>
EOF;
}
?> 

 

no change still error in line 4 :(

Link to comment
https://forums.phpfreaks.com/topic/149733-slideshow/#findComment-786288
Share on other sites

Ok. But I did not mean replacing all quotes. You cannot have quotes of the same type nested. So you can't have "abc"def"ghi", but either "abc'def'ghi" or 'abc"def"ghi'. Got it?

 

And then, if you use variables (it seems you do) you would need double quotes on the outside, and all quotes within would have to be be preceded by a backslash. So your quotes should look like "abc\"def\"ghi". If you don't need variables, you can prefer 'abc"def"ghi'. But don't mix it up.

 

Now go and try! :)

 

Link to comment
https://forums.phpfreaks.com/topic/149733-slideshow/#findComment-786297
Share on other sites

how does this look

 

<?
require_once "config.php";
if($_REQUEST[auto] == "on") {
$meta = "<meta http-equiv=\"refresh\" content=\"2;url=$PHP_SELF?image=$next_img&auto=on" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />";
$nav = "<a href=\"$PHP_SELF?image=$back_img&auto=on">Back</a> |
<a href="$PHP_SELF?image=$image&auto=off">Stop Slideshow</a> |
<a href="$PHP_SELF?image=$next_img&auto=on">Next</a>";
}
if($_REQUEST[auto] == "off" || !$_REQUEST[auto]) {
$meta = " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1" />";
$nav = "<a href=\"$PHP_SELF?image=$back_img&auto=off">Back</a> |
<a href="$PHP_SELF?image=$image&auto=on">Start Slideshow</a> |
<a href="$PHP_SELF?image=$next_img&auto=off">Next</a>";
}
if(!$_REQUEST[image]) { //Default thumbnil page
$i = 0;
foreach($arr_img as $var_img) { //Grabs all the image names in th array
if($var_img != "") { //Dont show first entery of the array that is blank
echo<<<EOF
<a href="$PHP_SELF?image=$i"><img src="../gallery/$var_img" /></a>
EOF;
}
$i++;
}
} else { //Show the slides
echo<<<EOF
<div align="center">
<img src="./gallery/$arr_img[$image]" /><br /><br />
$nav
</div>
EOF;
}
?> 

Link to comment
https://forums.phpfreaks.com/topic/149733-slideshow/#findComment-786299
Share on other sites

Generally it's a good start :)

 

You need to do this for every line. But please do not ask me to check every single quotation mark for you :P You need to do this on your own. I can only tell you the rule how it works. If it does not work, check the error message and check for correct quotes in the corresponding line. Now off to coding work! ;)

 

Link to comment
https://forums.phpfreaks.com/topic/149733-slideshow/#findComment-786303
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.