1

I want to display Database in HTML, but it does not update constantly when I change the data in the database, and i have to refreshing many times. Do you have any advice to optimize this ?

<div class="container">
    <div class="row">
        <?php
            while($result = $statement->fetch(PDO::FETCH_ASSOC))
            { 
                echo $result['temperature'];
            }
        ?>
    </div>
</div>
pcgben
  • 726
  • 7
  • 24
Maivinam
  • 33
  • 3

2 Answers2

0

This is an open ended question and likely to attract opinions and controversy. That being said, the technology you want is AJAX, or a JavaScript framework of some kind.

I would look into vue.js.

pcgben
  • 726
  • 7
  • 24
0

You need to use Ajax to somehow check if the table has been updated and if it has pull the new data again. You will also need a timer to trigger the check.

I've found an answer that might help you: Live update MySQL Data

George K
  • 481
  • 2
  • 13