<?php
include("file.php");
$pagesize=5;
$url=$_SERVER[REQUEST_URI];
$url=parse_url($url);
$url=$url[path];
$a=mysql_query("select * from message");
$b=mysql_num_rows($a);
if($_GET[page]){
$pagevel=$_GET[page];
$page=($pagevel-1)*pagesize;
$page.=',';
}else{
$page=1; //這裡加個未獲取到值的處理
}
if($b>$pagesize){
if($pagevel<=1) $pagevel=1;
echo "共 $b 條 <a herf=$url?page="($pagevel-1)">上一頁</a>" .
" <a herf=$url?page="($pagevel+1)">下一頁</a>";
}
$sql="select * from message limit $page ,$pagesize ";
$query=mysql_query($sql);
while($row=mysql_fetch_array($query)){
echo "<hr><br>"."$row[title]"."$row[context]";
}
?>