Range in PHP execution

0

I have done a PHP code that executes 3 queries, each query displays a message, I would like to know how to give a range of 800ms after the message to execute the next query, for example:

<?php
$sql_1 = "SELECT * FROM 'tbl' WHERE 'user_id' = '1';";
$query_1 = mysqli_query( $conexao, $sql_1 );
$count_1 = mysqli_num_rows( $query_1 );
echo $count_1 . "<br>\n";

// INTERVALO DE 800ms

$sql_2 = "SELECT * FROM 'tbl2' WHERE 'user_id' = '1';";
$query_2 = mysqli_query( $conexao, $sql_2 );
$count_2 = mysqli_num_rows( $query_2 );
echo $count_2 . "<br>\n";

// INTERVALO DE 800ms

$sql_3 = "SELECT * FROM 'tbl3' WHERE 'user_id' = '1';";
$query_3 = mysqli_query( $conexao, $sql_3 );
$count_3 = mysqli_num_rows( $query_3 );
echo $count_3 . "<br>\n";

// INTERVALO DE 800ms

header('Location: page/user/');
exit();
?>
    
asked by anonymous 28.09.2018 / 00:03

1 answer

1

You can use the sleep() function of PHP . It receives as parameter the amount of seconds. But I would advise you to research a way to implement Queues in your application.

$sql_1 = "SELECT * FROM 'tbl' WHERE 'user_id' = '1';";
$query_1 = mysqli_query( $conexao, $sql_1 );
$count_1 = mysqli_num_rows( $query_1 );
echo $count_1 . "<br>\n";

// INTERVALO DE 800ms
sleep( 0.8 );

$sql_2 = "SELECT * FROM 'tbl2' WHERE 'user_id' = '1';";
$query_2 = mysqli_query( $conexao, $sql_2 );
$count_2 = mysqli_num_rows( $query_2 );
echo $count_2 . "<br>\n";

// INTERVALO DE 800ms
sleep( 0.8 );

$sql_3 = "SELECT * FROM 'tbl3' WHERE 'user_id' = '1';";
$query_3 = mysqli_query( $conexao, $sql_3 );
$count_3 = mysqli_num_rows( $query_3 );
echo $count_3 . "<br>\n";

// INTERVALO DE 800ms
sleep( 0.8 );

header('Location: page/user/');
exit();
    
28.09.2018 / 16:18