We need an output script from the database without reloading the page, the site is hanging on the hosting, dynamic updates do not roll into any gate ...

DB: id - name - mess

The point is that when a line is added to the database, it is immediately displayed on the page of the site.

  • through JS, display directly in HTML ... $ (selector) .append (content, function (index, html)) - noxom
  • several ways. 1.Web sockets 2.ajax + triggers in the database for change + separate handler for tracking changes in the database. Nothing complicated, however, to get this "nothing complicated" you need to forget this non-language called PHP and use normal development tools. - Spouk
  • @Spouk web sockets will work on hosting? Because I read somewhere that hosting does not support this, only personal servers. - sasha-osipov2
  • @ sasha-osipov2 why not? This kit over TCP. Therefore, everything depends on the support of the browser used, but according to statistics, the support of web browsers in this website is more than 95%. So the answer is yes, everything will work. - Spouk
  • @Spouk and on mobile devices will be supported? - sasha-osipov2

1 answer 1

<!doctype html> <html> <head> <meta charset=utf-8> <meta http-equiv="Refresh" content="1" /> </head> <body> <?php $link = mysqli_connect('localhost', 'root', '', 'mybd'); if($result = mysqli_query($link, "SELECT * FROM table){ while($row = mysqli_fetch_assoc($result)){ echo $row['id'].$row['title']; echo 'Эти значения получены из БД'; } }?> </body> </html> 

This script gets the values ​​from mysql, and with the meta tag is updated every second