title: Random PHP/MySQL query updating every few minutes, not on refresh
body: <p>I have two tables in a MySQL databases, one of images, one of text:</p>
  
  <p>Table 1 (images):</p>
  
  <pre><code>&lt;img src="pngs/000.png"&gt;
  &lt;img src="pngs/001.png"&gt;
  &lt;img src="pngs/002.png"&gt;
  ...
  &lt;img src="pngs/199.png"&gt;
  </code></pre>
  
  <p>Table 2 (text):</p>
  
  <pre><code>"This is text 0."
  "This is text 1."
  "This is text 2."
  ...
  "This is text 1999."
  </code></pre>
  
  <p>I would like the page to display a random image, and ten lines of random text, which update on each access and every refresh.</p>
  
  <p>So far, I have this working perfectly on a local Web Apache server. However, when uploaded online, there are a couple of issues:</p>
  
  <ol>
  <li>The results update to new random results every ~five minutes, rather than on each refresh.</li>
  <li>The results are the same across devices, rather than unique for each instance.</li>
  </ol>
  
  <p>I am currently using the following method to select a random row from the MySQL database:</p>
  
  <pre><code>$query  = 'SELECT * FROM pngs ORDER BY RAND() LIMIT 1';
  </code></pre>
  
  <p>And referring to that script in the HTML with:</p>
  
  <pre><code>&lt;div class='img'&gt;&lt;?php include('pngs.php');?&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Is the delay in updating the images a problem with this implementation? Or am I misunderstanding the MySQL/PHP infrastructure and should be using Javascript instead?</p>
  
  <p>I would greatly appreciate any advice on how to produce the desired functionality.</p>
  
  <p><strong>*EDIT</strong></p>
  
  <p>Here is the full PHP code for the images.</p>
  
  <pre><code>&lt;?php
    require_once 'login2.php';
    $conn = new mysqli($hn, $un, $pw, $db);
    if ($conn-&gt;connect_error) die($conn-&gt;connect_error);
  
    $query  = "SELECT * FROM pngs ORDER BY RAND() LIMIT 1";
    $result = $conn-&gt;query($query);
    if (!$result) die($conn-&gt;error);
  
    $result-&gt;data_seek(1);
    $row = $result-&gt;fetch_array(MYSQLI_ASSOC);
    echo '&lt;img src="/pngs/'.$row['png'].'.png"&gt;';
  
    $result-&gt;close();
    $conn-&gt;close();
  ?&gt;
  </code></pre>
  
  <p>PHP script for the strings is similar, except uses</p>
  
  <pre><code>$query  = "SELECT txt FROM strings WHERE RAND()&lt;=0.011";
  </code></pre>
  
  <p>as I have read that this is a quicker way to select random rows from a large database.</p>