选择显示字体大小

杏林同学录(七)

留言簿部分:
   班级成员留言簿: 显示留言:class/notebook/index.php
<?
session_start(); // 开始session
if(!session_is_registered("userregister")(&#36;userregister==""))//检查是否注册,如userregister未注册或session为空值,重新注册.
{
echo "<a href=&#39;../index.php&#39;>请重新注册<br>";
exit;
}
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>留言簿</title>
<style type="text/css">
<!--
.blue9 {  font-size: 9pt; color: #0099ff; text-decoration: none}
.black9 {  font-size: 9pt; text-decoration: none}
.purple10 {  font-size: 10pt; color: #9900ff; text-decoration: none}
.white12 {  font-size: 12pt; color: #ffffff; text-decoration: none}
a:visited {  color: #ffffff}
a:link {  color: #ffffff}
-->
</style>
</head>
<body bgcolor="#ffffff">
<?php
include ("../config.php");
&#36;result = mysql_query("select * from notebook",&#36;db);
&#36;row=mysql_num_rows(&#36;result);//查看查询结果有多少行
&#36;max=&#36;row; //帖子总数
//设每页显示10篇,可自行设定,&#36;p总页数,&#36;page第几页,&#36;low 从第几行开始读,&#36;x 读取几行
if (!&#36;page){ &#36;page=1;}//&#36;page默认值为1
&#36;p=ceil(&#36;max/10);//页数为&#36;max/10的最大整数
&#36;low=10*(&#36;page-1);
if(&#36;page==&#36;p&&(&#36;max%10)<>0){&#36;x=(&#36;max%10);} else {&#36;x=10;}//如果是最后一页,且不是10的整倍数,读取&#36;max除以10的余数,否则取10
if(&#36;max==0){&#36;x=0;}//如果没有帖子,&#36;x取0
&#36;result = mysql_query("select * from notebook order by time desc limit &#36;low,&#36;x",&#36;db);//按照帖子的时间降序查询
?>
<table width="98%" border="0" cellspacing="0" cellpadding="0" height="61">
  <tr>  
    <td height="62" width="34%"><img src="../image/classlogo.gif" width="224" height="60"  border="0"></td>
    <td height="62" width="66%">  
      <div align="center"><img src="../image/note.gif" width="410" height="60"><img src="../image/y1.gif" width="60" height="60"></div>
    </td>
  </tr>
</table>
<table width="95%" border="1" cellspacing="0" cellpadding="0" height="253" bordercolordark="#ffffff" bordercolorlight="#003399" align="center">
  <tr>  
    <td height="250">  
      <div align="center"></div>
      <table width="95%" border="0" cellspacing="0" cellpadding="0" height="32" bgcolor="#3366ff">
        <tr>  
          <td width="26%" class="white12" height="23"><a href="../guest.php" class="white12">首页</a>  
            &gt; 留言簿</td>
          <td width="48%" class="white12" height="23">  
            <?php
          echo "帖子总数: &nbsp;",&#36;max," &nbsp;&nbsp;第";
          for (&#36;n=1;&#36;n<=&#36;p;&#36;n++){
          echo "<a href=index.php?page=&#36;n>&#36;n</a>&nbsp;";
          }
          echo "页";
          ?>
          </td>
          <td width="15%" height="23"><a href="addnote.php"><img src="../image/newthread.gif" width="91" height="21" border="0"></a></td>
          <td width="11%" height="23"><a href="delnote.php"><span class="white12">留言管理</span></a></td>
        </tr>
      </table>  
<?php
   for (&#36;i=0;&#36;i<=(&#36;x-1);&#36;i++) {
   &#36;user=mysql_result(&#36;result,&#36;i,&#39;user&#39;);
   &#36;time=mysql_result(&#36;result,&#36;i,&#39;time&#39;);
   &#36;ip=mysql_result(&#36;result,&#36;i,&#39;ip&#39;);
   &#36;title=mysql_result(&#36;result,&#36;i,&#39;title&#39;);
   &#36;nnote=mysql_result(&#36;result,&#36;i,&#39;nnote&#39;);
   &#36;yresult = mysql_query("select * from user where user=&#39;&#36;user&#39;",&#36;db);//读取成员数据库
   &#36;name=mysql_result(&#36;yresult,0,&#39;name&#39;);
   &#36;signature=mysql_result(&#36;yresult,0,&#39;signature&#39;);//读取个人签名
   &#36;email=mysql_result(&#36;yresult,0,&#39;email&#39;);
   &#36;face=mysql_result(&#36;yresult,0,&#39;face&#39;);
   &#36;face=&#39;../image/face/icon&#39;.&#36;face;
     
echo "<table width=&#39;100%&#39; border=&#39;0&#39; cellspacing=&#39;0&#39; cellpadding=&#39;0&#39; height=107&#39; bordercolor=&#39;#ffffff&#39;> <tr bgcolor=&#39;#eeeeee&#39;>";  
echo "<td width=&#39;10%&#39; height=&#39;33&#39; bgcolor=&#39;#eeeeee&#39; class=&#39;blue9&#39;>&nbsp;<img src=&#39;&#36;face.gif&#39; width=&#39;32&#39; height=&#39;32&#39;></td>";
echo        "<td width=&#39;16%&#39; height=&#39;33&#39; bgcolor=&#39;#eeeeee&#39; class=&#39;blue9&#39;>留言人:&#36;name</td>";
echo        "<td width=&#39;41%&#39; height=&#39;33&#39; bgcolor=&#39;#eeeeee&#39; class=&#39;blue9&#39;>发表于:&#36;time</td>";
echo        "<td width=&#39;12%&#39; height=&#39;33&#39; bgcolor=&#39;#eeeeee&#39; class=&#39;blue9&#39;><a href=&#39;mailto:&#36;email&#39;><img src=&#39;../image/email.gif&#39; width=&#39;16&#39; height=&#39;16&#39; border=0></a></td>";
echo        "<td width=&#39;21%&#39; height=&#39;33&#39; class=&#39;blue9&#39;><img src=&#39;../image/ip.gif&#39; width=&#39;13&#39; height=&#39;15&#39;> &nbsp;&#36;ip</td>  </tr> <tr>";  
echo        "<td colspan=&#39;5&#39; class=&#39;purple10&#39; height=&#39;33&#39;>标题:&#36;title</td> </tr>";
echo        "<tr bgcolor=&#39;#ffffff&#39;><td colspan=&#39;5&#39; class=&#39;black9&#39; height=&#39;37&#39;>留言内容:&#36;nnote<br>----------------------<br>&#36;signature</td></tr></table>";
}
mysql_close(&#36;db);
?>     
    </td>
</tr>
</table>
</body>
</html>
添加留言:class/notebook/addnote.php
<?
session_start(); // 开始session
if(!session_is_registered("userregister")(&#36;userregister==""))//检查是否注册,如userregister未注册或session为空值,重新注册.
{
echo "<a href=&#39;../index.php&#39;>请重新注册<br>";
exit;
}
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>添加留言</title>
<style type="text/css">
<!--
.white12 {  font-size: 12pt; color: #ffffff; text-decoration: none}
-->
</style>
</head>
<body bgcolor="#ffffff">
<table width="98%" border="0" cellspacing="0" cellpadding="0" height="61">
  <tr>  
    <td height="62" width="34%"><img src="../image/classlogo.gif" width="224" height="60" border="0"></td>
    <td height="62" width="66%">  
      <div align="center"><img src="../image/note.gif" width="410" height="60"><img src="../image/y1.gif" width="60" height="60"></div>
    </td>
  </tr>
</table>
<?php
include ("../config.php");
if (&#36;submit){
&#36;time=date("y年m月d日 h:i:s a");
&#36;ip=&#36;remote_addr;//留言人ip地址
&#36;title=strip_tags(&#36;top);
&#36;nnote=nl2br(strip_tags(&#36;content));//先去掉html标记,再将换行符转成 <br>。
if (!&#36;title!&#36;nnote){           //检查是否填写完整
      echo "对不起,您必须填所有内容!<br>"."<a href=&#39;javascript:history.back()&#39;>返回</a>";
      exit; }
   //写入数据库
&#36;sql="insert into notebook (user,time,ip,title,nnote) values (&#39;&#36;userregister&#39;,&#39;&#36;time&#39;,&#39;&#36;ip&#39;,&#39;&#36;title&#39;,&#39;&#36;nnote&#39;)";
&#36;result = mysql_query(&#36;sql,&#36;db);
mysql_close(&#36;db);
echo "留言成功!";
}
?>
<table width="99%" border="1" cellspacing="0" cellpadding="0" align="center" bordercolor="#3366ff">
  <tr bgcolor="#3366ff">  
    <td width="81%" class="white12" height="26"><a href="../../main.php" class="white12">首页</a>  
      &gt; <a href="index.php" class="white12">留言簿</a> &gt; 添加留言</td>
    <td width="19%" class="white12" height="26"><a href=&#39;index.php&#39; class="white12">查看留言</a>  
    </td>
  </tr>
  <tr>  
    <td colspan="2">
      <form name="form1" method="post" action="addnote.php">
        <table width="99%" border="0" cellspacing="0" cellpadding="0">
          <tr>  
            <td>  
              <div align="center">标题<br>
                <input type="text" name="top" size="50">
                <br>
                内容<br>
                <textarea name="content" cols="50" rows="6"></textarea>
                <br>
                <input type="submit" name="submit" value="确定">
                <input type="reset" name="cancel" value="重写">
              </div>
            </td>
          </tr>
        </table>
              </form>
    </td>
  </tr>
</table>
<p><a href="main.php?user=<? echo &#36;user?>" class="white12"><br>
  </a></p>
</body>
</html>


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons