niceguy82 Posted May 9, 2010 Share Posted May 9, 2010 hello guys this is my first post to your forum i hope that you can help me with my problem i have that script to take last images added to mysql database and slidshow in main page with intrval 10 second but there is a problem with code it's show first image and after 10 second it show up all the other images in one time here i'll post you the code i have the first file slideshow.php <html> <head> <script language="javascript"> function jah_switch(url,target) { if (document.getElementById(target).innerHTML != '') { document.getElementById(target).innerHTML = ''; } else { jah(url,target); } } function Switch(url,target) { // native XMLHttpRequest object if (window.XMLHttpRequest) { req = new XMLHttpRequest(); req.onreadystatechange = function() {jahDone(target);}; req.open("GET", url, true); req.send(null); // IE/Windows ActiveX version } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); if (req) { req.onreadystatechange = function() {jahDone(target);}; req.open("GET", url, true); req.send(); } } } function jahDone(target) { // only if req is "loaded" if (req.readyState == 4) { // only if "OK" if (req.status == 200) { results = req.responseText; document.getElementById(target).innerHTML = results; } else { document.getElementById(target).innerHTML="خطأ:\n" + req.statusText; } } } </script> </head> <body> <?php require('config.php'); echo '<div id="photo_show">'; $get_phos = mysql_query ("select Car_pic from car order by Car_id desc LIMIT 10"); $phos= mysql_fetch_array($get_phos); echo '<img width="200" src="'.$phos['Car_pic'].'" />'; echo '</div>'; // echo "<script>setInterval('switch(\'photo_show.php\', \'photo_show\')', 10000);</script>"; echo "<script>setInterval('Switch('photo_show.php', 'photo_show\)', 10000);</script>"; ?> </body> </html> and the second file photo_show.php <?php include('config.php'); $get_phos = @mysql_query ("select Car_pic from car order by Car_id desc LIMIT 10") or trigger_error(mysql_error(),E_USER_ERROR); while($phos = @mysql_fetch_array($get_phos)) { echo '<img width="200" src="'.$phos['Car_pic'].'" />'; } ?> and this the output of code on the server http://www.2worldshopping.com/test/slidshow.php Quote Link to comment Share on other sites More sharing options...
niceguy82 Posted May 10, 2010 Author Share Posted May 10, 2010 no one can solve this problem this is my first post i hope you can help me guys i want to pull image path from database for last images added , then slidshow the images by ajax that all what i need Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.