title: Simple Javascript MYSQL checking function
body: <p>I'm not very skilled in web developing by the moment but i've managed to create a web application with PHP that queries a MYSQL Database and shows data in HTML.</p>
  
  <p>I would like to check if the table has changed using a timestamp field that I already created and that updates on every insertion. Comparing two timestamps (the previous and the current) is the key,</p>
  
  <p>but I don't handle javascript that much.</p>
  
  <p>How can I pass a parameter to my hastablechanged.php file (the previous timestamp) and simply return a flag (1: changed, 0: not changed) to javascript?
  and... how would be a basic javascript function to run a timer and call hastablechanged.php posting old_timestamp and receiving the flag and then update the div?</p>
  
  <p>I've been googling but the solutions I have found are very complex and I know i just need a javascript function that I don't find out how to write.</p>
  
  <p>This is hastablechanged.php:</p>
  
  <pre><code>&lt;?php 
  include 'config.php';
  include 'opendb.php';
  
  $table = "data_table";
  $query_timestamp = "select timestamp from {$table} where id = 0;";
  $timestamp = mysql_query("{$query_timestamp}");
  if (!$timestamp) {
  die("query failed");
  }
  
  $row_timestamp = mysql_fetch_array($timestamp);
  echo $row_timestamp['timestamp'];
  ?&gt;
  </code></pre>
  
  <p>And this is my index.php</p>
  
  <pre><code>&lt;!DOCTYPE HTML PUBLIC&gt;
  
  
  &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
      &lt;meta http-equiv="Content-Style-Type" content="text/css"&gt;
      &lt;title&gt;Data values&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;div id=data&gt;
      &lt;? include("table.php");?&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>where "table.php" is the php code that selects the data and displays it drawing a html table.</p>
  
  <p>I would thank a lot any help, as I'm stuck in this issue for finishing my degree project</p>