I have a php code which displays a random file on pageload and on refresh.
This code is in ../ads/food/responce.php which you will see in the other script below.
<?php
$ad = glob("../ads/food/*.php");
$adfood = $ad[mt_rand(0, count($ad) -1)];
include ($adfood);
?>
I am wanting to rotate the files displayed without having to refresh the page.
(“like an image slider does”)
What i have tried:
I have tried a script to refresh the div, but it seems to display a warning and not the file. You can see the error here http://whatanswered.com/food/what-can-i-do-with-cornflour.php
<script type="text/javascript">
$(document).ready(function() {
setInterval(function()
{
$('#button').fadeOut("fast").load('../ads/food/responce.php').fadeIn("slow");
}, 10000);
});
</script>
<div id="button">
<?php include("../ads/food/responce.php");?>
</div>
It is just because the path
("../ads/food/*.php")doesnt lead to a folder that contains any php (ie :http://whatanswered.com/ads/ads/food).You have to write the path
../../ads/food/*.phpthis will lead tohttp://whatanswered.com/ads/food/(which contains some php files)