I am trying to create an FB news feed, but to display content from a database. My code already reads the number of rows in the table, but it needs to refresh the page before updating the html content.
Here is my code:
part of my html file:
<section id="reportcontent"></section>
<script>
(function refreshNews()
{
$("#reportcontent").load("php/ajax.php");
})();
setInterval('refreshNews()',1000);
</script>
content ajax.php
<?php
require("database.php");
$sql = "SELECT * FROM report";
$res = odbc_exec($conn,$sql);
while($feedItem = odbc_fetch_array($res))
{
echo "hello! <br>";
}
?>
As you can see, each row of my table will display welcome text. But in order to view the new number of rows, I need to refresh the page. Thanks for the help!
source
share