Hi friends,
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.
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,
but I don't handle javascript that much.
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?
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.
This is hastablechanged.php:
<?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'];
?>
And this is my index.php
<!DOCTYPE HTML PUBLIC>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>Data values</title>
</head>
<body>
<div id=data>
<? include("table.php");?>
</div>
</body>
</html>
where "table.php" is the php code that selects the data and displays it drawing a html table.
I would thank a lot any help, as I'm stuck in this issue for finishing my degree project