son Posted September 14, 2009 Share Posted September 14, 2009 I am still a bit ropy with JavaScript and do not have the slightest clue how to make the basic slideshow loop. My code so far is: <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Slideshow</title><?php$query2 = "SELECT * FROM slides WHERE showroom = 0 ORDER BY rand()";$result2 = mysqli_query ($dbc, $query2); if (mysqli_num_rows($result2) > 0) { echo "<script type=\"text/javascript\">\n"; echo "<!--\n"; $i = 1; while ($row = mysqli_fetch_array ($result2, MYSQLI_ASSOC)) { $img_id = $row['img_id']; $img1 = $row['img1']; echo "var image" . $i . "=new Image()\n"; echo "image" . $i . ".src=\"slides/main/" . $img1 . "\"\n"; if ($i ==1) { $feature = "slides/main/" . $img1; } $i++; }echo "//-->\n";echo "</script>\n"; }?><style type="text/css"> body {background-color:#d1cc98; text-align:center; padding:30px;}</style></head><body><img src="<?php echo $feature; ?>" name="slide" width="600" height="400" /><script><!--//variable that will increment through the imagesvar step=1function slideit(){//if browser does not support the image object, exit.if (!document.images)returndocument.images.slide.src=eval("image"+step+".src")step++//call function "slideit()" every 2.5 secondssetTimeout("slideit()",2500)}slideit()//--></script></body> I am sure it is just a basic thing, but would really appreciate any hints...Son Link to comment Share on other sites More sharing options...
son Posted September 14, 2009 Author Share Posted September 14, 2009 Just found a solution. Got with php count of rows from db and then use: step++if (step == <?php echo $max;?>)step = 1 Seems to work fine...Son Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.