Hello,
Can someone tell me why this doesn't work? It is a slideshow function written in javascript, using a PHP array. I get the last image of the slideshow in my view box, but when I click "Next," I get the entire array in a string - not just the next image.
PHP
<?
$sql = "SELECT ID,title,image FROM slideshow WHERE sID=$sID";
$result = mysql_query($sql);
$imgarray=array();
$z=0;
while ($myrow = mysql_fetch_row($result)) {
$image = str_replace($bad,"",$myrow[2]);
$imgarray[$z]=$image;
z++;
}
$count = count($imgarray);
?>
JAVASCRIPT
<SCRIPT Language="JavaScript">
<!--
var picture = new Array("<?php
while (list($key, $val) = each($imgarray)) {
echo "$val";
}
if ($zz!=$count) {
echo ",";
}
?>")
var picNumber=1
var numberofPics = picture.length
function previousPicture(){
if(picNumber > 1){
picNumber--
}
document.myPicture.src=picture[picNumber-1]
}
function nextPicture(){
if(picNumber < numberofPics){
picNumber++
}
document.myPicture.src=picture[picNumber-1]
}
//-->
</script>
BODY
<?
echo "<img src=$image name=myPicture>";
?>
<BR>
<a href="JavaScript:previousPicture()">Previous</a>
<a href="JavaScript:nextPicture()">Next</a>
When I print out my array, it looks correct:
images/image1.jpg,images/image2.jpg,images/image3.jpg...
but this is the string I get as my image source when I click "next".
Any help will REALLY be appreciated. I've been toiling with this for some time, and just keep getting nowhere.
Thanks so much.
Geogal