I have found the below code and modify a bit..somehow, it didn display the updated records.
Can someone knows what the problem with below coding?
connect.inc is the database connection and the page itself is saved as 'test.php'
Thanks.
<html>
<head>
<script type="text/javascript">
function createRequestObject() {
var ro;
var browser = navigator.appName;
if(browser == 'Microsoft Internet Explorer') {
ro = new ActiveXObject("Microsoft.XMLHTTP");
} else {
ro = new XMLHttpRequest();
}
return ro;
}
var http = createRequestObject();
function sndReq(action) {
http.open('get', 'test.php');
http.onreadystatechange = handleResponse;
http.send(null);
}
function handleResponse() {
if(http.readyState == 4) {
var response = http.responseText;
document.getElementById('foo').innerHTML = response;
}
}
setInterval('sndReq()', 1);
</script>
</head>
<body>
<div id="foo">
<?php
include("inc/connect.inc");
$q1 = "SELECT EVENT_DESC FROM EVENTS";
$r1 = mysql_query($q1);
$EVENT_DESC = mysql_result($r1,0,0);
echo $EVENT_DESC;
?>
</div>
</body>
</html>