Jump to content

PHP Slideshow in Firefox


comports

Recommended Posts

HI Folk,

New to this Forum and fairly new to PHP. I have an issue with firefox and wonder if you can help.

Quite simple really. It reads the contents of a folder into an array and display number 1. Increments the variable, refreshes the page and displays image 2 and so on. All fine in IE. BUt when I view it in Forefox it displays image 1, refreshes and jumps straight to the last image in the folder....??

Help.. ??? ???

Thanks in advance.
Ash
Link to comment
Share on other sites

Hi Perad, Thanks fo rthe quick response. My code..

[code]<?php
error_reporting(0);
$folder = ("../cane-corso/images/gallery/");
$num = $_GET["num"];
$dir = opendir($folder);
print"<HTML><HEAD><TITLE>Cane Corso Slide Show</TITLE><META NAME=\"Author\" CONTENT=\"Ashley Byrne\"><META NAME=\"Keywords\" CONTENT=\"Image Gallery Slideshow\"><META NAME=\"Description\" CONTENT=\"\"><link rel=\"stylesheet\" href=\"style2.css\"></HEAD><BODY bgcolor=\"#FF99CC\"><center><table border=\"5\" cellspacing=0 cellpadding=0 width=\"100%\" height=\"100%\" bgcolor=\"#FF99CC\"><table bgcolor=\"#FF99CC\">";

$dir = opendir($folder);
$i=1;
while ($a = readdir($dir)) {
if($a != "." && $a != ".." && $a != "text"){
$files[$i] = $a;
++$i;
}
}
$total = count($files);
if ($num==""){
$num=="1";
}

// resize the image if its too big
$maxwidth="600";
list($width, $height, $type, $attr) = getimagesize($gallery.$folder.$files[$num]);
if($width>$maxwidth){
$widthpc = round(($maxwidth/$width)*100);
$width = round(($width*$widthpc)/100);
$height = round(($height*$widthpc)/100);
$attr="width=".$width." height=".$height;
}
Else{
$attr="width=".$width." height=".$height;
}

print "<tr><td><center><b>".substr($files[$num],0,-4)."</b>&nbsp;&nbsp;&nbsp;&nbsp;(". $num. " of ". $total.")</b></td></tr>";
print "<tr><td><center><img src=\"".$gallery.$folder.$files[$num]."\" ".$attr." border=1><br></td></tr>";
print "<tr><td><br><center><a href=\"javascript:parent.window.close()\"><font color=\"white\">--|  End slideshow  |--</a></td></tr>";
while ($num < $total){
$num = ($num+1);
print "<META HTTP-EQUIV=\"refresh\" content=\"3; URL=?folder=".$folder."&num=".$num."\"></td></tr></table>";
}
?>[/code]
Link to comment
Share on other sites

when in ff, go to the first picture, quickly right click the page, go to view source, what do you have in there for the

[code]
<META HTTP-EQUIV=\"refresh\" content=\"3; URL=?folder=".$folder."&num=".$num."\">
[/code]
? that'll tell you if its an issue with the redirecting, or where its a math issue...
i also cleaned up your code a little :-)

[code]
<?php
$folder = ("../cane-corso/images/gallery/");
$num = $_GET["num"];
if (empty($num)) $num=="1";
$dir = opendir($folder);
print"<HTML><HEAD><TITLE>Cane Corso Slide Show</TITLE><META NAME=\"Author\" CONTENT=\"Ashley Byrne\"><META NAME=\"Keywords\" CONTENT=\"Image Gallery Slideshow\"><META NAME=\"Description\" CONTENT=\"\"><link rel=\"stylesheet\" href=\"style2.css\"></HEAD><BODY bgcolor=\"#FF99CC\"><center><table border=\"5\" cellspacing=0 cellpadding=0 width=\"100%\" height=\"100%\" bgcolor=\"#FF99CC\"><table bgcolor=\"#FF99CC\">";

$dir=opendir($folder);
while ($a = readdir($dir)) if($a != "." && $a != ".." && $a != "text") $files[] = $a;
$total = count($files)-1;

$maxwidth="600";
list($width, $height, $type, $attr) = getimagesize($gallery.$folder.$files[$num]);
if($width>$maxwidth){
$widthpc = round(($maxwidth/$width)*100);
$width = round(($width*$widthpc)/100);
$height = round(($height*$widthpc)/100);
$attr="width=".$width." height=".$height;
}else $attr="width=".$width." height=".$height;

print "<tr><td><center><b>".substr($files[$num],0,-4)."</b>&nbsp;&nbsp;&nbsp;&nbsp;(". $num. " of ". $total.")</b></td></tr>";
print "<tr><td><center><img src=\"".$gallery.$folder.$files[$num]."\" ".$attr." border=1><br></td></tr>";
print "<tr><td><br><center><a href=\"javascript:parent.window.close()\"><font color=\"white\">--| End slideshow |--</a></td></tr>";
while($num < $total){
$num++;
print "<META HTTP-EQUIV=\"refresh\" content=\"3; URL=?folder=".$folder."&num=".$num."\"></td></tr></table>";
}
?>
[/code]
Link to comment
Share on other sites

Thanks Taith,

It's very interesting but I guess it goes back to the "Firefox does not process php" line. My source does contain the correct line

[code]<META HTTP-EQUIV="refresh" content="3; URL=?folder=../cane-corso/images/gallery/&num=2">[/code]

but also contains the same code with each of the image numbers in it so I get:

[code]
<META HTTP-EQUIV="refresh" content="3; URL=?folder=../cane-corso/images/gallery/&num=2">
<META HTTP-EQUIV="refresh" content="3; URL=?folder=../cane-corso/images/gallery/&num=3">
<META HTTP-EQUIV="refresh" content="3; URL=?folder=../cane-corso/images/gallery/&num=4">
<META HTTP-EQUIV="refresh" content="3; URL=?folder=../cane-corso/images/gallery/&num=5">
<META HTTP-EQUIV="refresh" content="3; URL=?folder=../cane-corso/images/gallery/&num=6">[/code]

etc... all the way to the last imagenumber in the array.. I guess it reads the last line and refreshes but using the last number..!

Is there a way to stop this..?
Link to comment
Share on other sites

yup... ie reads <meta> tags top down, ff reads bottom up...

scrap this
[code]
while($num < $total){
$num++;
print "<META HTTP-EQUIV=\"refresh\" content=\"3; URL=?folder=".$folder."&num=".$num."\"></td></tr></table>";
}
[/code]

use this in its place
[code]
echo "<META HTTP-EQUIV=\"refresh\" content=\"3; URL=?folder=".$folder."&num=".$num."\"></td></tr></table>";
[/code]
Link to comment
Share on other sites

Thanks Taith,

Your are a superstar..! I had to mod it a bit to get it move to the next image but that's ace. See it working here:-

[url=http://www.comports.net/cane-corso/pictures.php?folder=../cane-corso/images/gallery/&show=y&num=1]http://www.comports.net/cane-corso/pictures.php?folder=../cane-corso/images/gallery/&show=y&num=1[/url] and click on slideshow..

Thanks a Million
Ash
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.