I am using JavaScript to refresh div
content and load a PHP file containing a query to get data from MySQL.
This is my jQuery code:
<script type="text/javascript">
var auto_refresh = setInterval(
function ()
{
$('#random_notes').load('include/blocks/random_stories.php').fadeIn("slow");
}, 2000); // refresh every 10000 milliseconds
</script>
<div id="random_notes" class='random'>s</div>
This is my PHP file:
<?php
include "../../cp/config.php";
$query = mysql_query("SELECT title FROM stories ORDER BY RAND()");
$random_story = mysql_fetch_object($query);
echo $random_story->title;
?>
The page loads and shows one row. The refresh does not get another row from the database. What am I missing?
Is there another good piece of code to do the same thing? This code needs cleaning cache whenever I do anything.