Jump to content

banner freezing after some modifications


vin_akleh

Recommended Posts

i have a banner that changes image every couple of seconds that retrieve the images from a static images like so:

old code:

var image1=new Image()
image1.src="uploads/firstcar.gif"
var image2=new Image()
image2.src="uploads/secondcar.gif"
var image3=new Image()
image3.src="uploads/thirdcar.gif"
var image4=new Image()
image3.src="uploads/cat.gif"

 

<div class="banner">
<p class="banner_image">
<a href="http://www.w3.org/">
<img src="banner/123.jpg" name="slide" width="290px">
<script>
<!--
//variable that will increment through the images
var step=1
function slideit(){
//if browser does not support the image object, exit.
if (!document.images)
return
document.images.slide.src=eval("image"+step+".src")
if (step<3)
step++
else
step=1
//call function "slideit()" every 2.5 seconds
setTimeout("slideit()",2500)
}
slideit()
//-->
</script>
</p>
<p class="banner">
<a href="http://www.w3.org/">banner</a>
</p>
</div>

 

know i want it to retrieve the images from database like so

New modifications:

<?php $count_im=1;
$req=mysql_query("select * from banner");
while ($res=mysql_fetch_array($req)){ ?>
var image<?php echo $count_im; ?> =new Image()
image<?php echo $count_im; ?>.src="<?php echo $res["banner"]; ?>"
<?php $count_im++;
}?>

 

but the problem is that it know freezes on the last image, it doesn't loop!! any ideas how to fix it

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.