guestbook.php:
include ("connect.rec");
$qh=mysql_query("SELECT COUNT(*) AS rcnt FROM guestbook");
$data=mysql_fetch_array($qh);
$nr=$data["rcnt"];
//判斷位移量參數是否傳遞給了指令碼,如果沒有就使用預設值0
if (empty($offset))
{
$offset=0;
} //查詢結果(這裡是每頁20條,但你自己完全可以改變它)
//$result=mysql_query("SELECT * from guestbook ORDER BY time desc LIMIT $offset, 5"); $result=mysql_query("SELECT * from guestbook LIMIT $offset, 5");
//顯示返回的5條記錄
while ($data=mysql_fetch_array($result)) { printf("姓名:%s ",$data["name"]); printf("EMAIL:%s ",$data["mail"]); printf("個人首頁:%s ",$data["url"]); printf("來自:%s ",$data["ip"]); printf("留言時間:%s ",$data["time"]); printf("主題:%s ",$data["title"]); printf("內容:%s ",$data["ly"]); printf(""); }
//下一步,要寫出到其它頁面的連結
if($offset) //如果位移量是0,不顯示前一頁的連結 { $preoffset=$offset-5; print "前一頁 n"; }
//計算總共需要的頁數
$pages=ceil($nr/5); //$pages變數現在包含所需的頁數
for ($i=1; $i <= $pages; $i++)
{
$newoffset=5*$i-5;
print "$i n";
}
//檢查是否是最後一頁 $next = $offset+5; if ($next<$nr) { print "下一頁 n"; } printf("返回") ?>
|
ly.php:
include ("connect.rec");
$name = $T1;
$mail = $T2;
$url = $T3;
$title = $T4;
$time = date( "Y-m-j H:i:s" );
$ip = getenv("REMOTE_ADDR");
$ly = $S1;
$result = mysql_query("insert into guestbook (name,mail,url,ip,time,title,ly) values ('$name','$mail','$url','$ip','$time','$title','$ly')");
if ($result == 1)
{
echo("留言成功!");
printf("");
}
else
{
echo("留言失敗!");
printf("返回");
}
?>
可到http://xinai.oso.com.cn/class/guesttap.php查看
【本文著作權歸作者與奧索網共同擁有,如需轉載,請註明作者及出處】
http://www.bkjia.com/PHPjc/316694.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/316694.htmlTechArticleguestbook.php: head meta http-equiv=Content-Language content=zh-cn meta http-equiv=Content-Type content=text/html; charset=gb2312 title/title STYLEA:link { COLOR: #002878; TEXT-DECO...