PunkSktBrdr01
08-07-2003, 12:35 PM
I made a picture viewer/slide show script with PHP and JavaScript, and I keep getting errors. I keeps saying "expected ';'", even though there is already a semicolon there. Here's the code:
<?
$pics = "mrc1.jpg,mrc2.jpg,mrc3.jpg,mrc4.jpg,mrc5.jpg,mrc6.jpg";
$src = explode(",", $pics);
$sizeof = sizeof($src);
$rows = ceil($sizeof / 4);
$cols = floor($sizeof / $rows);
$i = 0;
?>
<html>
<head>
<title>Pics</title>
<style>
img.thumb {
border:2;
border-color:#000000;
border-style:solid;
width:80px;
height:60px;
cursor:hand;
}
img.large {
border:0;
width:270px;
height:202px;
}
</style>
<script language="JavaScript">
function slideShow(dir) {
var pics = <?= $pics; ?>;
var pic_num = split(",", pics);
var i += dir;
if(i <= 0) {
document.slide_form.slide_left.disabled = true;
}
if(i >= pic_num.length) {
document.slide_form.slide_right.disabled = true;
}
}
</script>
</head>
<body>
<?
echo "<br>\n";
echo "<table width=\"100%\">\n";
echo "<tr><td><center>\n";
echo "<form name=\"slide_form\" onSubmit=\"return false;\">\n";
echo "<input type=\"button\" name=\"slide_left\" value=\"<<<\" onClick=\"slideShow(-1);\">\n";
echo "<img name=\"img\" width=\"270\" height=\"202\" src=\"$src[0]\">\n";
echo "<input type=\"button\" name=\"slide_right\" value=\">>>\" onClick=\"slideShow(1);\">\n";
echo "</form>\n";
echo "</center></td></tr>\n";
for($x = 0; $x < $rows; $x++) {
echo "<tr><td><center>\n";
for($y = 0; $y < $cols; $y++) {
echo " <img src=\"$src[$i]\" class=\"thumb\" width=\"80\" height=\"60\" onClick=\"document.img.src='$src[$i]'\"> ";
$i++;
}
echo "</td></tr>";
}
echo "</table>";
?>
The live code is here (http://www.radioactiverabbit.com/slideshow).
Thanks for any help!
<?
$pics = "mrc1.jpg,mrc2.jpg,mrc3.jpg,mrc4.jpg,mrc5.jpg,mrc6.jpg";
$src = explode(",", $pics);
$sizeof = sizeof($src);
$rows = ceil($sizeof / 4);
$cols = floor($sizeof / $rows);
$i = 0;
?>
<html>
<head>
<title>Pics</title>
<style>
img.thumb {
border:2;
border-color:#000000;
border-style:solid;
width:80px;
height:60px;
cursor:hand;
}
img.large {
border:0;
width:270px;
height:202px;
}
</style>
<script language="JavaScript">
function slideShow(dir) {
var pics = <?= $pics; ?>;
var pic_num = split(",", pics);
var i += dir;
if(i <= 0) {
document.slide_form.slide_left.disabled = true;
}
if(i >= pic_num.length) {
document.slide_form.slide_right.disabled = true;
}
}
</script>
</head>
<body>
<?
echo "<br>\n";
echo "<table width=\"100%\">\n";
echo "<tr><td><center>\n";
echo "<form name=\"slide_form\" onSubmit=\"return false;\">\n";
echo "<input type=\"button\" name=\"slide_left\" value=\"<<<\" onClick=\"slideShow(-1);\">\n";
echo "<img name=\"img\" width=\"270\" height=\"202\" src=\"$src[0]\">\n";
echo "<input type=\"button\" name=\"slide_right\" value=\">>>\" onClick=\"slideShow(1);\">\n";
echo "</form>\n";
echo "</center></td></tr>\n";
for($x = 0; $x < $rows; $x++) {
echo "<tr><td><center>\n";
for($y = 0; $y < $cols; $y++) {
echo " <img src=\"$src[$i]\" class=\"thumb\" width=\"80\" height=\"60\" onClick=\"document.img.src='$src[$i]'\"> ";
$i++;
}
echo "</td></tr>";
}
echo "</table>";
?>
The live code is here (http://www.radioactiverabbit.com/slideshow).
Thanks for any help!