似乎我对这个问题更恼火,我不知道为什么会发生这种情况。非常感谢任何帮助。下面是我的代码:
<?php include('header.php'); ?>
<body>
<table cellpadding="0" cellspacing="0" border="0" class="table" id="">
<thead>
<tr>
<th>Date</th>
<th>User</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$query = $link->mysql_query("select * from activity_log ORDER BY activity_log_id DESC")or die(mysql_error());
while($row = $query->fetch()){
?>
<tr>
<td><?php echo $row['date']; ?></td>
<td><?php echo $row['username']; ?></td>
<td><?php echo $row['action']; ?></td>
</tr>
<?php } ?>
就用
$query = mysql_query("select * from activity_log ORDER BY activity_log_id DESC");
if (!$query) {
die('Invalid query: ' . mysql_error());
}
then in while loop
while($row = mysql_fetch_assoc($query))
阅读mysql_query
手册和mysql_fetch_assoc
手册
注意
此扩展在PHP 5.5.0中已弃用,并将在将来被删除。相反,应该使用MySQLi或PDO_MySQL扩展名。更多信息请参见MySQL:选择API指南和相关FAQ。此函数的替代函数包括:
- mysqli_query ()
- PDO: query ()
使用
$query = mysql_query("select * from activity_log ORDER BY activity_log_id DESC")or die(mysql_error());
while($row = mysql_fetch_assoc($query)){
不是$query = $link->mysql_query("select * from activity_log ORDER BY activity_log_id DESC")or die(mysql_error());
while($row = $query->fetch()){