我想知道有没有办法从数据库中的表中回显第一行等待/休眠 5 秒,然后回显第二行?
预先感谢您的帮助!
$conn = mysqli_connect('localhost', 'root', '','database');
$strSql=$conn->query("SELECT words FROM load ORDER BY id ASC ");
if($strSql->num_rows >0) {
while ($row = $strSql->fetch_assoc()) {
$rows[]=$row;
foreach($rows as $row){
$words1=$row['words'];
echo '<div class="animatedText"> '.$words1.'</div>';
//let's say sleep(5); and then print second row???
}
}
}
最佳答案
尝试使用 output buffering .例如:
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);
}
}
关于php回显第一行等待/ sleep 然后回显第二行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35890629/