我想使用 Javascript Ajax 每隔给定的秒数执行此脚本。(这个想法是避免重新加载页面)
这是脚本:
include("databaseCONNECTION.php");
$seconds=1;
$sql = "SELECT * FROM " . $dbDatabase .".chat";
$lines = [];
foreach($dbConnection->query($sql) as $row) {
$line = '<span class="time-message">' . $row['when_send'] . '-' . '</span>';
$line .= '<label class="nick-message"><strong>' . $row['sender'] . ': ' . '</strong></label>';
//$lines[] = $line . ": " . $row['message'];
echo $line . $row['message'] . "<br/><hr/>";
}
有只小跳蛙
阿晨1998