留言簿部分:
班級成員留言簿: 顯示留言: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 "
留言人:$name | "; echo "
發表於:$time | "; echo "
| "; echo "
$ip |
"; echo "
| 標題:$title |
"; echo "
留言內容:$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 "留言成功!";
}
?>
" class="white12">
以上就介紹了5460同學錄 杏林同學錄七,包括了5460同學錄方面的內容,希望對PHP教程有興趣的朋友有所協助。