0

I have an array with 4 rows, I Want to show them one by one, But only one and with an Interval.

Like: Row1 show for 5secs -> Row2 show for 5secs -> Row3 show for 5secs -> Row4 show for 5secs

I tried this, but that is not working. It loads much time and than showing only one and doing nothing more.

$count = mysqli_num_rows($result) -1;
 for ($i=0; $i < $count; $i++) { 
    $random = rand(0, $count);
    echo json_encode($data[$random]);
    unset($data[$random]);
    $count -= 1;
    sleep(5);
}
Xcodian Solangi
  • 2,342
  • 5
  • 24
  • 52

1 Answers1

0

I think the solution could be to simply to deliver all the data in PHP to a javascript client, and have the client simply show the information using a simple setTimeout function or perhaps using CSS animation.

similar to this:

Using CSS for fade-in effect on page load

or perhaps this:

https://www.sitepoint.com/jquery-settimeout-function-examples/

that you can get rid of the PHP sleep() call.

Felipe Valdes
  • 1,998
  • 15
  • 26