2017-03-09 148 views
-2

我想從數據庫表中檢索內容並使用php腳本顯示它們。我成功檢索並顯示了內容,並使用元標記每5秒刷新一次內容。該頁面仍然不令人耳目一新。你們能幫我解決這個問題嗎?在這裏,我附上我的代碼:刷新網頁的內容

<html> 
<head> 
<meta http-eqiv="refresh" content="2"> 
</head> 
<body> 
<?php 
session_start(); 
$_SESSION['username']; 
$con=mysqli_connect("localhost","root","","oracle"); 
$result=mysqli_query($con,"SELECT * from message order by timestamp DESC"); 
while($row=mysqli_fetch_row($result)) 
{ 
echo "<font color='red'><b><i>" .$row['2']." 
</i></b></font> &nbsp;says:    <font color='green'><b><i>" 
. $row['0']. "</i></b></font>&nbsp;at:" . 
$row['1']. "<br>"; 
} 
?> 
</body> 
</html> 
+0

您可能還需要對'在session_start閱讀一些文檔()'。 – miken32

+0

你也可以看看AJAX。你不必用ajax刷新整個頁面,而只需要你需要的頁面塊 – JapanGuy

回答

0

。在你的代碼一個錯字:

http-equiv="refresh"