So, I have this code below which gets the data from my database, but I want this data to 'Refresh' Every 5 seconds so that when something new is put in the database which is matching the specifications shows up. (I don't want the page to refresh for this, only data...)
$sql = "SELECT * FROM items WHERE reference = '1' ORDER BY datePosted asc LIMIT 5";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$title = $row["titel"];
$description = $row["description"];
}
} else {
echo "Nothing found";
}
I've been looking for AJAX and PHP ways to do this, but I just don't seem to figure it out... Any help / info is appreciated!