21,893
社区成员




require_once('common.php');
$countRow = mysql_num_rows(mysql_query("SELECT count(*) FROM gb_content"), MYSQL_BOTH); //这样求总行数
$count = $countRow[0]; //总行数
$_GET['page'] = intval($_GET['page']);
if ($_GET['page']<=0) {
$_GET['page'] = 1;
}
$lines = 10; // 每页行数
$page = $_GET['page'];// 当前页
$limit = ($page - 1) * $lines;//起启行
$total = ceil($count/$lines); // 总页数
mysql_query("set names 'utf8'");//加上这句试试
$result = mysql_query("SELECT * FROM gb_content order by id desc limit " .$limit. ','.$lines.'');//查询数据
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {// 取一条数据
?>
<table width="700" border="0" cellspacing="0" cellpadding="0" class="tb">
<tr>
<td class="bg"><b>[<?php echo htmlentities($row['username']) ?>]</b> 发表于:<?php echo htmlentities($row['insert_time']) ?></td>
</tr>
<?php
require_once('common.php');
$countRow = mysql_fetch_array(mysql_query("SELECT count(*) FROM gb_content"), MYSQL_BOTH);
$count = $countRow[0]; //总行数
$_GET['page'] = intval($_GET['page']);
if ($_GET['page']<=0) {
$_GET['page'] = 1;
}
$lines = 10; // 每页行数
$page = $_GET['page'];// 当前页
$limit = ($page - 1) * $lines;//起启行
$total = ceil($count/$lines); // 总页数
$result = mysql_query("SELECT * FROM gb_content order by id desc limit " .$limit. ','.$lines.'');//查询数据
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {// 取一条数据
?>
<table width="700" border="0" cellspacing="0" cellpadding="0" class="tb">
<tr>
<td class="bg"><b>[<?php echo htmlentities($row['username']) ?>]</b> 发表于:<?php echo htmlentities($row['insert_time']) ?></td>
</tr>
<tr>
<td><?php echo htmlentities($row['content']) ?></td>
</tr>
<tr>
<td align="right"><a href="edit.php?id=<?php echo $row['id'] ?>">修改</a> <a href="delete.php?id=<?php echo $row['id'] ?>">删除</a></td>
</tr>
</table>
<?php
}
mysql_free_result($result);
if ($page>1) {
echo '<a href="?page=1">首页</a> <a href="?page='. ($page-1) .'">上一页</a>';
}
if ($page<$total) {
echo ' <a href="?page=' . ($page+1) .'">下一页</a> <a href="?page='.$total.'">末页</a>';
}
?>