So, I need to develop a function that will invoke when the page is loaded at the start and will extract the value from the database and display the same. The value of cod and bod will keep on updating in the database so what I need is to display that updated value onto a page without reloading or refreshing. Thank you.
code:
<?php
include("dbconfig.db");
?>
<script>
function update_data()
{
</script>
<?php
$execute_query = "SELECT cod,bod,tss FROM front_end_data WHERE
slave_id=1";
$output=mysqli_query($conn,$execute_query);
$result_data = mysqli_fetch_assoc($output);
$cod_data = $result_data['cod'];
$bod_data = $result_data['bod'];
$tss_data = $result_data['tss'];
?>
<script>
setTimeout(update_data, 5000);
}
window.onload = function()
{
update_data();
};
</script>
<html>
<head>
<title>
test
</title>
</head>
<body>
<h2>COD DATA: <?php $cod_data ?></h2>
<h2>BOD DATA: <?php $bod_data ?></h2>
<h2>TSS DATA: <?php $tss_data ?></h2>
</body>
</html>