<?php
include "dataconnect.php";
include "header.php";
$each_page=EACH_PAGE;//每页最多显示留言数
$offset= intval($_GET['offset']);//记录偏移量
$keyword= $_GET['keyword'];//关键字,用于搜索
//构造检索条件
if($keyword){
$where="usercontent like '%$keyword%' or rcontent like '%$keyword%'";
$title="搜索结果";
}
else{
$where="1=1";
$title="最新留言";
}
//总记录数
$sql="select count(*) from liuyan where $where";
$result=mysql_query($sql);
$row=mysql_fetch_row($result);
$total=$row[0];
//规范$offset
if($offset<0)
$offset=0;
elseif ($offset> $total)
$offset=$total;
$result= mysql_query($sql);
//查询当前页记录
$sql2="select * from liuyan where $where order by liuyanid desc limit $offset,$each_page";
$result2=mysql_query($sql2) ;
$num=mysql_num_rows($result2);
?>
<script>
function vaildform(obj){
if(obj.keyword.value==''||obj.keyword.value.length<3){
alert("您没有填写搜索关键词,或者您的关键词太短!\n请重新填写至少3个关键词!");
return false;
}
else{
return true;
}
}
</script>
<center>
<table border="0" cellpadding="0" cellspacing="0" width="750" class="titlebar" bgcolor="Blue">
<tr>
<td class="titlebar_l"></td>
<td class="titlebar_t"><font color="Red">==<?php echo $title;?>==</font></td>
<td class="titlebar_r"></td>
</tr>
</table>
<?php
if($num>0){
while($data=mysql_fetch_array($result2)){
$id=$data['liuyanid'];
$hide=$data['hide'];
$name=$data['username'];
$sex=($data['usersex'] )? '帅哥':'美女';
$email=$data['useremail'];
$page=$data['userpage'];
$face=$data['userface'];
$qq=$data['userqq'];
$time=$data['usertime'];
$content=$data['usercontent'];
if($data['rcontent']){
$rtime=$data['rtime'];
$rcontent=$data['rcontent'];
}
?>
<table border="1" cellpadding="0" cellspacing="0" width="750" class="textbox_l">
<tr>
<td width="5" rowspan="4" class="border_l"></td>
<td height="1" class="bgline"></td>
<td width="5" rowspan="4" class="border_r"></td>
</tr>
<tr>
<td height="8"></td>
</tr>
<tr>
<td valign="top">
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" width="144">
<div align="center"><strong><?php echo $name; ?></strong><br><br>
<img src="image/face/<?php echo $face ?>.gif" border="0" width="100" height="150 "><br><br>性别:<?php echo $sex ?><br><br>
</div></td>
<td width=1 class=bgline><?php
$star="*";
for($i=0;$i<=15;$i++){
echo "<font color=red>".$star."</font>\n";
}
?> </td>
<td valign="top" width="575">
<img border="0" src="image/email.gif" width="30" height="30">信箱
<img border="0" src="image/home.gif" width="30" height="30">主页
<img border="0" src="image/time.gif" width="30" height="30">发表时间:<?php echo $time ?>
<?php if($_SESSION['isADMIN']){?>
<a href="rcontent.php ? id=<?php echo $id ?>">回复</a>
<a href="delete.php ? id=<?php echo $id ?>" onclick="javascript:if(confirm('确实要删除这条留言吗?')) return true;else return false;">删除</a>
<?php } ?>
<hr align="left" width="100%" size="1" color=green noshade>
<table border="0" width="96%" cellpadding="4" cellspacing="4">
<tr>
<td class="booktext"><div class="booktext">
<?php
if($_SESSION['isADMIN'] || !$hide){
echo $content;}else{ echo "<b>这是一条悄悄话,只有管理员能看哦!</b>";}
?>
</div></td>
</tr>
</table>
</td>
</tr>
<?php
//如果有回复信息
if($rcontent){ ?>
<tr>
<td valign="top" align="center"><hr align="right" size="1" color=green noshade width="100%">版主回复<br><?php echo $rtime?></td>
<td width=1 class=bgline><?php
$star="*";
for($i=0;$i<=5;$i++){
echo "<font color=red>".$star."</font>\n";
}
?></td>
<td valign="top">
<hr size="1" width="100%" color=green noshade align="left">
<table border="0" width="96%" cellpadding="4" cellspacing="4" class="booktext">
<tr>
<td class="rcontent"><?php echo $rcontent?></td>
</tr>
</table>
</td>
</tr>
<?php } ?>
</table>
</td>
</tr>
<tr>
<td height="8"></td>
</tr>
</table>
<?php
}
}else{
?>
<h3>暂时没有留言</h3>
<?php
}
?>
<!--底边-->
<table border="0" width="750" class="hemline">
<tr>
<td class="hemline_l"></td>
<td class="hemline_t"><img style="width:1;height:0"></td>
<td class="hemline_r"></td>
</tr>
</table>
<!--搜索和分页-->
<table border="0" height="34">
<tr>
<td nowrap width="100">
<table border="0" >
<form action="read.php" method="GET" onsubmit="return vaildform(this)">
<tr>
<td nowrap>搜索:<input class="text" name="keyword" size="13" value="<?php echo htmlspecialchars($keyword)?>"></td>
</tr>
</form>
</table>
</td>
<td align="right" nowrap>
<p>共<font color="Red"><b
用PHP写的网络留言板
5星 · 超过95%的资源 需积分: 9 185 浏览量
2009-10-09
23:31:51
上传
评论
收藏 406KB RAR 举报
dengchao1988
- 粉丝: 0
- 资源: 1
最新资源
- tomcat安装及配置教程.md
- 51单片机贴片心形灯原理图PCB程序 亚克力外壳.dwg资料
- 户型为单家独院式图纸编号D068-三层-20.60&13.40米-施工图.dwg
- 农村小别墅图纸编号D067-三层-10.00&11.50米- 施工图.dwg
- 三层独栋别墅图纸编号D066-三层-12.00&12.00米- 施工图.dwg
- 农村小别墅图纸编号D065-三层-14.40&18.55米-施工图.dwg
- 基于YOLOv8检测高铁吊弦缺陷实现的系统的Python源码+文档说明+训练源文件+模型.zip
- 三层农村小别墅图纸编号D064-三层-13.80&22.20米-施工图.dwg
- 三层别墅图纸编号D063-三层-13.57&17.40米- 施工图.dwg
- STC IAP15F2K61S2单片机i2c 接口PCF8591-ADC实验+DAC实验 KEIL例程源码+开发板硬件原理图
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈