Random PHP/MySQL query updating every few minutes, not on refresh -


i have 2 tables in mysql databases, 1 of images, 1 of text:

table 1 (images):

<img src="pngs/000.png"> <img src="pngs/001.png"> <img src="pngs/002.png"> ... <img src="pngs/199.png"> 

table 2 (text):

"this text 0." "this text 1." "this text 2." ... "this text 1999." 

i page display random image, , ten lines of random text, update on each access , every refresh.

so far, have working on local web apache server. however, when uploaded online, there couple of issues:

  1. the results update new random results every ~five minutes, rather on each refresh.
  2. the results same across devices, rather unique each instance.

i using following method select random row mysql database:

$query  = 'select * pngs order rand() limit 1'; 

and referring script in html with:

<div class='img'><?php include('pngs.php');?></div> 

is delay in updating images problem implementation? or misunderstanding mysql/php infrastructure , should using javascript instead?

i appreciate advice on how produce desired functionality.

*edit

here full php code images.

<?php   require_once 'login2.php';   $conn = new mysqli($hn, $un, $pw, $db);   if ($conn->connect_error) die($conn->connect_error);    $query  = "select * pngs order rand() limit 1";   $result = $conn->query($query);   if (!$result) die($conn->error);    $result->data_seek(1);   $row = $result->fetch_array(mysqli_assoc);   echo '<img src="/pngs/'.$row['png'].'.png">';    $result->close();   $conn->close(); ?> 

php script strings similar, except uses

$query  = "select txt strings rand()<=0.011"; 

as have read quicker way select random rows large database.


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -