Home > Backend Development > PHP Tutorial > 5460 Classmate Record Xinglin Classmate Record 7

5460 Classmate Record Xinglin Classmate Record 7

WBOY
Release: 2016-07-29 08:33:47
Original
1092 people have browsed it

留言簿部分:
   班级成员留言簿: 显示留言:class/notebook/index.php
session_start(); // 开始session
if(!session_is_registered("userregister")||($userregister==""))//检查是否注册,如userregister未注册或session为空值,重新注册.
{
echo "请重新注册
";
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<=$p;$n++){
          echo "$n ";
          }
          echo "页";
          ?>
          
留言管理
  
   for ($i=0;$i<=($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 "";  
echo "";
echo        "";
echo        "";
echo        "";
echo        "  ";  
echo        "";
echo        "
 留言人:$name发表于:$time  $ip
标题:$title
留言内容:$nnote
----------------------
$signature
";
}
mysql_close($db);
?>     
    



添加留言:class/notebook/addnote.php
session_start(); // 开始session
if(!session_is_registered("userregister")||($userregister==""))//检查是否注册,如userregister未注册或session为空值,重新注册.
{
echo "
请重新注册
";
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标记,再将换行符转成

if (!$title||!$nnote){           //检查是否填写完整
      echo "对不起,您必须填所有内容!
"."
返回";
      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 "留言成功!";
}
?>

    
    
    
  
    
    
首页  
      > 留言簿 > 添加留言
查看留言  
    

      

        
            
            
  
              
标题

                
                

                内容

                
                

                
                
              

                                                                                                        

< a href="main.php?user=" class="white12">



< ;/HTML>

The above has introduced the 5460 classmate record Xinglin classmate record 7, including the content of the 5460 classmate record. I hope it will be helpful to friends who are interested in PHP tutorials.


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template