I need to find a way of refreshing a div (id: box1_middle) whenever certain conditions in my database change. I have 5 'cells' if you like, and basically, i need a representation of each of those 5 cells in a single div on my page. If i was to do this purely with php i would do something along the lines of:
<?PHP if($query9_row['a_trailerarrival'] == NULL && $query10_row['a_endsort'] == NULL)
{
echo "Cell 1 content --> Box 1";
}
else if($query9_row['a_trailerarrival'] != NULL && $query10_row['a_endsort'] == NULL)
{
echo "Cell 2 content --> Box 1";
}
else if($query9_row['a_trailerarrival'] != NULL && $query10_row['a_endsort'] != NULL)
{
echo "Cell 3 content > Box 1";
} ?>
Etc..
So basically, I want the content of box 1 to display a variety of different things, depending upon the sql query in the php script. This works absolutely fine if i do it with purely php and when the page is loaded then Box 1 displays my desired content but the only problem is, i dont want the user to refresh the page for the content to change, i want the query to be run every second so that if the condition in the dB was to change within that second, something else would be displayed upon the next Div refresh. I have tried toying around with the jQuery, SetInterval(code, 1000);
but so far i have not succeeded!
Any suggestions would be greatly appreciated.
Thanks in advance!
** EDIT **
I used the following jQuery:
<script type="text/javascript">
var auto_refresh = setInterval(
function ()
{
$('#box1_middle').load('b1_middle.php').fadeIn("slow");
}, 1000);
Where the contents of b1_middle.php is pretty much the php code in the script above.
** EDIT 2 **
Well basically, for testing purposes it works ok with just echoing a line in the php script. But for the actual purpose what i want it to do is display a different countdown timer for each condition. e.g. countdown timer 1 displays when both cells are empty, countdown 2 timer displays when cell1 !=Null && cell2 == NULL etc..
So i incorporated some Javascript countdown code into my script and this jQuery does not load it.
What would be perfect is if i could have the div content on my page as the - Is there any way to refresh a DIV without having to load external code into it? Just literally refresh the container?