杏林同学录(七)

留言簿部分:
班级成员留言簿: 显示留言:class/notebook/index.php

请重新注册 ```
``` "; exit; } ?> ```留言簿``` include ("../config.php"); $result = mysql_query("SELECT * FROM notebook",$db); $row=mysql_num_rows($result);//查看查询结果有多少行 $max=$row; //帖子总数 //设每页显示10篇,可自行设定,$p总页数,$page第几页,$low 从第几行开始读,$x 读取几行 if (!$page){ $page=1;}//$page默认值为1 $p=ceil($max/10);//页数为$max/10的最大整数 $low=10*($page-1); if($page==$p&&($max%10)<>0){$x=($max%10);} else {$x=10;}//如果是最后一页,且不是10的整倍数,读取$max除以10的余数,否则取10 if($max==0){$x=0;}//如果没有帖子,$x取0 $result = mysql_query("select * from notebook ORDER BY time DESC limit $low,$x",$db);//按照帖子的时间降序查询 ```
首页 > 留言簿``` echo "帖子总数:  ",$max,"   第"; for ($n=1;$n&lt;=$p;$n++){ echo "<a href="index.php?page=$n">$n</a> "; } echo "页"; ```留言管理
``` for ($i=0;$i&lt;=($x-1);$i++) { $user=mysql_result($result,$i,'user'); $time=mysql_result($result,$i,'time'); $ip=mysql_result($result,$i,'ip'); $title=mysql_result($result,$i,'title'); $nnote=mysql_result($result,$i,'nnote'); $yresult = mysql_query("SELECT * FROM user where user='$user'",$db);//读取成员数据库 $name=mysql_result($yresult,0,'name'); $signature=mysql_result($yresult,0,'signature');//读取个人签名 $email=mysql_result($yresult,0,'email'); $face=mysql_result($yresult,0,'face'); $face='../image/face/icon'.$face; echo "<table border="0" bordercolor="#FFFFFF" cellpadding="0" cellspacing="0" height="107'" width="100%"> <tr bgcolor="#eeeeee">"; echo "<td bgcolor="#eeeeee" class="blue9" height="33" width="10%"> <img height="32" src="$face.gif" width="32"/></td>"; echo "<td bgcolor="#eeeeee" class="blue9" height="33" width="16%">留言人:$name</td>"; echo "<td bgcolor="#eeeeee" class="blue9" height="33" width="41%">发表于:$time</td>"; echo "<td bgcolor="#eeeeee" class="blue9" height="33" width="12%"><a href="mailto:$email"><img border="0" height="16" src="../image/email.gif" width="16"/></a></td>"; echo "<td class="blue9" height="33" width="21%"><img height="15" src="../image/ip.gif" width="13"/>  $ip</td> </tr> <tr>"; echo "<td class="purple10" colspan="5" height="33">标题:$title</td> </tr>"; echo "<tr bgcolor="#ffffff"><td class="black9" colspan="5" height="37">留言内容:$nnote<br/>\----------------------<br/>$signature</td></tr></table>"; } mysql_close($db); ```
``` 添加留言:class/notebook/addnote.php 请重新注册 ```
``` "; exit; } ?> ```添加留言
``` include ("../config.php"); if ($submit){ $time=date("Y年m月d日 H:i:s A"); $ip=$REMOTE_ADDR;//留言人ip地址 $title=strip_tags($top); $nnote=nl2br(strip_tags($content));//先去掉html标记,再将换行符转成 <br/>。 if (!$title||!$nnote){ //检查是否填写完整 echo "对不起,您必须填所有内容!<br/>"."<a href="javascript:history.back()">返回</a>"; exit; } //写入数据库 $sql="INSERT INTO notebook (user,time,ip,title,nnote) VALUES ('$userregister','$time','$ip','$title','$nnote')"; $result = mysql_query($sql,$db); mysql_close($db); echo "留言成功!"; } ```
首页 > 留言簿 > 添加留言查看留言
标题

内容


```
Published At
Categories with Web编程
Tagged with
comments powered by Disqus