To jest tylko przykład:
CREATE TABLE `date12x` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`timestamp1` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
+----+---------------------+
| id | timestamp1 |
+----+---------------------+
| 1 | NULL |
+----+---------------------+
create event dsfdsfa on schedule every 10 second ends '2019-04-14 01:55:01' do
update date12x set timestamp1 = (timestamp(timediff(current_timestamp, '2019-04-15 03:03:02')));
receive1.php:
<?php
$mys = new mysqli('localhost', 'root', '', 'forumpasjainformatyki');
$res = ($mys->query('select * from date12x;'));
while($tile = $res->fetch_array()) {
echo $tile[0]. ' ' . $tile[1];
}
?>
front_1.php:
<body style="background: darkolivegreen; white-space: pre-wrap;">
function xhra() {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = alertContents;
xhr.open('GET', 'http://127.0.0.1:8000/forumpasja_informatyki/receive1.php');
xhr.send();
function alertContents() {
if(xhr.readyState === XMLHttpRequest.DONE) {
if(xhr.status === 200) {
document.body.textContent = (xhr.responseText) + "\r\n";
} else {
alert('There was a problem with the request.');
}
}
}
}
setInterval(function() {
xhra();
}, 10000);
</body>
Zamiast setInterval powinno być chyba zdarzenie odpowiadające za zmieniający się content (xhr), że gdy pojawi się nowy request, żeby od razu wykonał akcję zamiast takiego odświeżania co 10 sekund.