php echo first row wait/sleep then echo second row

后端 未结 2 810
野性不改
野性不改 2021-01-25 17:13

I would like to know is there a way to echo first row from table in database wait/sleep for 5 seconds and then echo the second row?

Thank you in advance for your help!

相关标签:
2条回答
  • 2021-01-25 17:33

    you can use sleep() function:

    echo '<div class="animatedText"> ';
    while ($row = $strSql->fetch_assoc()) {
    
          $rows[]=$row;
    
           foreach($rows as $row){
               $words1=$row['words'];
    
               echo $words1;
               sleep(5);
    
               }
    
           }
    echo '</div>';
    

    read more

    0 讨论(0)
  • 2021-01-25 17:35

    try using output buffering. For example:

    header( 'Content-type: text/html; charset=utf-8' );
    
    while ($row = $strSql->fetch_assoc()) {
          $rows[]=$row;
           foreach($rows as $row){
                $words1=$row['words'];
                echo '<div class="animatedText"> ';
                echo $words1;
                echo '</div>';
                flush();
                ob_flush();
                sleep(5);
               }
           }
    
    0 讨论(0)
提交回复
热议问题