Jump to content

Recommended Posts

Hello all,

 

I'm relatively new to all of this, but making progress....

I figure this has come up before, but couldn't fin anything by search or browsing.

 

I have an sql table that is cron updated every two minutes from externally generated data in table X columns a,b,c,... .

 

As part of more complicated site, I have one body element page (selected by a tab in the header) that does various sql queries on the data in table X and displays the data.  I need this to rerun the queries and update the displayed results every 2 minutes or so as well.

 

However, the standard solutions do not seem to be working:

<META HTTP-EQUIV="refresh" CONTENT="15">

 

A refresh button refreshes the entire site, and not just this element.

 

<FORM>

        <INPUT TYPE="button" onClick="history.go(0)" VALUE="Force Flight Data Refresh">

    </FORM>

 

I hope it is clear. 

Any ideas of how I could get this to work? 

 

Thanks,

Kalle

 

Here is a snippet of the code on that page for what it's worth...

 

</head>

<body>

<div id="header">

        <center><h2><font color="red">TRAFFIC INFORMATION</font></h2> 

</div>

<div id="navigation">

</div>

<div id="content">

    <!-- refresh button -->

    <FORM>

        <INPUT TYPE="button" onClick="history.go(0)" VALUE="Force Flight Data Refresh">

    </FORM>

</center>

    <?php

    $IDS->db_build($db);

    $IDS->db_query($db,$res,"SELECT * FROM `Pilots` WHERE `dest`='KORD'");

    echo "<h5>Arrivals to O'Hare:</h5>";

    while ($arr_row = mysql_fetch_assoc($res))

    {

        echo "<font color=yellow>".$arr_row['callsign']."</font> using route:  ". $arr_row['route']."<br>";

    }

//end queries

    //close connect to sql database

    mysql_close($con)

</div>

 

<div id="footer">

 

</div>

</body>

</html>

You would want to use AJAX for this. Basically the page with have a JavaScript function that will trigger every n seconds to get the new data. The JavaScript will make a request to the server (e.g. PHP code) to get the new data. The PHP code will get the data and return it back to the JavaScript code. The JavaScript code will then take the returned data and repopulate the appropriate content on the page.

 

There are tons of tutorials available out there on how to do this. trying to explain the entire process in a forum post is not realistic.

Your browser is probably caching the page.

<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>

 

This should dis-able caching.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.