Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Yes it can be implement in a much better way</strong>. As you are using same <code>Database connection configuration</code> every-time, there is <strong>no need to connect and close database on page refresh</strong>.<em>Connecting to database server every-second is very expensive call</em>.</p> <p>Why don't you <code>just reload/refresh the query statement</code>?</p> <p>The idea is:</p> <p>Use <a href="http://php.net/manual/en/features.persistent-connections.php" rel="nofollow noreferrer">Persistent Database Connection</a></p> <p>Refer <strong>BlaM</strong> answer in following <a href="https://stackoverflow.com/questions/50303/persistent-db-connections-yea-or-nay">post</a> to know why persistent connections is optimal. </p> <p>Put the queries in a separate div say #load.</p> <pre><code> echo '&lt;div id="load"&gt;'; // SELECT sql query $sql = "SELECT * FROM `Value`"; // perform the query and store the result $result = $conn-&gt;query($sql); if (!$result) print 'Error!'; // if the $result contains at least one row if ($result-&gt;num_rows &gt; 0) { // output data of each row from $result while($row = $result-&gt;fetch_assoc()) { $output=$row; print_r($output); } } else { print '0 results'; } echo '&lt;/div&gt;'; </code></pre> <p>Use jquery function to <strong>refresh only #load div</strong></p> <pre><code>&lt;script type="text/javascript"&gt; var auto_refresh = setInterval( function () { $("#load").load("filename.php #load"); }15000); // refresh every 1 second &lt;/script&gt; </code></pre> <p><strong>I had implemented this for auto-refresh leaderboard page.It worked perfectly and server didn't crash even in 50 hrs</strong>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload