<!DOCTY
PE ht
ML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.
org/TR/xhtml1/DTD/xhtml1
-transitional.dtd">
<html
XMlns="http://www.w3.org/1999/xhtml">
<head>
<
Meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>银子留言板 Version 1.0</title>
</head>
<link
href="css.css" rel="stylesheet" type="text/css" />
<body>
<?
PHP session_start(); ?>
<div id="head">
<div id="head_l">
<ul>
<li><a href="index.
PHP">偶要看留言</a></li>
<li><a href="post.
PHP">偶要发表</a></li>
<?
PHP //session_start();//DOFY
同学指出本句前不能有任何
输出内容,就此改正
if($_SESSION["key"]
==1){//如果
获取的SESSION为1则
显示管理项
?>
<li><a href="ad
minexit.
PHP">
退出管理</a></li>
<?
}
else
{
?>
<li><a href="admin.
PHP">偶要管理</a></li>
<?}?>
</ul>
</div>
<div id="head_r">银子留言板 Version 1.0</div>
</div>
<?
PHP $counterFile="conter.xml";
function dis
playCounter($counterFile){
$fp = fopen($counterFile,"rw");
$num =
fgets($fp,5);
$num += 1;
PRint "<div id=\"footer\">银子留言板 Version 1.0 您是第 "."$num"." 位无聊的银</div>";
exec("rm -rf $counterFile");
exec("echo $num > $counterFile");
}
if(!
file_exists($counterFile)){
exec("echo 0 > $counterFile");
}
displayCounter($counterFile);
?>
</body>
</html>
<?
PHP require_once("conn.
PHP");
require_once("header.
PHP");
session_start();
//
分页代码开始 $pagesize = 10;//设置每页
显示条数
$rs =
MysqL_query("select count(*)
From lo");//取得记录总数,计算总页数用
$myrow =
MysqL_fetch_array($rs);
$numrows = $myrow[0];//计算总记录
$pages = intval($numrows/$pagesize);
if($numrows%$pagesize)$pages++;//设置页数
if(isset(
$_GET['page']))
{
$page = intval($_GET['page']);
}
else
{
$page = 1;//设为
第一页 }
$offset = $pagesize*($page-1);//计算记录偏移量
//
分页代码结束
$
sql = "select id,username,sex,qq,email,info,ip,DATE_FORMAT(submit_time, '%Y年%m月%d日 %T' ) f
rom lo order by id desc limit $offset,$pagesize";//用到了DATE-FORMAT
格式化日期格式
$result =
MysqL_query($
sql);
$num =
MysqL_num_rows($result);
if($num>0){
while($row =
MysqL_fetch_array($result))
{
//echo print_r($row);
if($row[2]=="男")//这个使性别改成你想要的
名称^_^
{
$sex = "帅锅";
}
else
{
$sex = "美女";
}
?>
<div id="show">
<p class="num">第 [<?= $row[0] ?>] 条留言<p>
<p class="unline">留言人:<span class="blue"><?= $row[1]?></span> 性别:<?= $sex ?> 留言时间:<?= $row[7] ?> <? if($row[3]) {?> <a href="http://wpa.qq
.COM/ms
Grd?V=1&Uin=<?= $row[3] ?>&Site=http://www.loai.cn&Menu=yes"><
img src="img/qq.gif" alt="<?= $row[3]?>" /></a><? } ?><? if($row[4]){ ?> <a href="mailto:<?= $row[4] ?>"><img src="img/email.gif" alt="<?= $row[4]?>" /></a> <? }?><? if($_SESSION["key"]==1){ ?> IP:<?= $row[6] ?> <a href="update.
PHP?wuleying&id=<?= $row[0]?>">更改</a> <a href="delete.
PHP?wuleying&id=<?= $row[0]?>">
删除</a><?}?></a></p>
<p class="blue">留言
内容:</p>
<div id="show_info"><?= nl2
br(htmlspecialchars($row[5])) ?></div>
</div>
<?
PHP }
}
else
{
echo "<div id=\"show\">无数据
......</div>";
}
?>
<div id="show_page">
<p>
<?
PHP $
First=1;
$p
rev=$page-1;
$next=$page+1;
$last=$pages;
if($page==1&&$pages>1)
{
echo "
首页 | ";
echo "
上一页 | ";
echo "<a href=\"index.
PHP?page=".$next."\">
下一页</a> | ";
echo "<a href=\"index.
PHP?page=".$last."\">尾页</a> | ";
}
els
eif($page>=1&&$page!=$pages&&$num>0)
{
echo "<a href=\"index.
PHP?page=".$first."\">
首页</a> | ";
echo "<a href=\"index.
PHP?page=".$prev."\">
上一页</a> | ";
echo "<a href=\"index.
PHP?page=".$next."\">
下一页</a> | ";
echo "<a href=\"index.
PHP?page=".$last."\">尾页</a> | ";
}
elseif($page==$pages&&$page!=1)
{
echo "<a href=\"index.
PHP?page=".$first."\">
首页</a> | ";
echo "<a href=\"index.
PHP?page=".$prev."\">
上一页</a> | ";
echo "
下一页 | ";
echo "尾页 | ";
}
elseif($page==$pages)
{
echo "
首页 | ";
echo "
上一页 | ";
echo "
下一页 | ";
echo "尾页 | ";
}
else
{
echo "
首页 | ";
echo "
上一页 | ";
echo "
下一页 | ";
echo "尾页 | ";
}
?>
共 <span><?= $pages ?></span> 页 | 当前第 <span><?= $page ?></span> 页 | 共 <span><?=$numrows ?></span> 条留言</p>
</div>
<?
PHP MysqL_close();
?>
<?
PHP require_once("footer.
PHP");
?>