1

I want to display data values from an external mysql database in wordpress pages. I have used this php code which works fine inside a php widget :

<?php

$host = "xxx.xxx.xxx.xx";
$user = "user";
$pass = "Password2000!";
$db_name = "my_database";

//create connection
$dbcon = mysqli_connect($host, $user, $pass, $db_name);

//test if connection failed
if (mysqli_connect_errno()) {
    die("connection failed: "
        . mysqli_connect_error()
        . " (" . mysqli_connect_errno()
        . ")");
}
$sqlget = " SELECT Value FROM Points WHERE Name_ID = 'Hall' ";
$sqldata = mysqli_query($dbcon, $sqlget);
while ($row = mysqli_fetch_array($sqldata)) {
    echo sprintf('%.1f', $row['Value']);
    echo " °C";
}
}

?>

But my question is how to refresh the value periodically without reloading the page. Best regards.

atymic
  • 3,093
  • 1
  • 13
  • 26
hicham2000
  • 15
  • 2

0 Answers0