//頁面數與頁面資料存取
if( ($_GET['newspage']<=0)||(!isset($_GET['newspage'])) ){
$newspage1=1;
}else{
$newspage1=$_GET['newspage'];
}
if( ($_GET['groups']<1)||(!isset($_GET['groups'])) ){
$groups1=1;
}else{
$groups1=$_GET['groups'];
}
if( ($_POST['group']<1)||(!isset($_POST['group'])) ){
$group1=$groups1;
}else{
$group1=$_POST['group'];
}
//計算公告數量
if($group1==1){//總覽
$sql1="SELECT COUNT(*) AS total FROM labnews";
}else{//指定類別
$sql1="SELECT COUNT(*) AS total FROM labnews WHERE newsgroup='".$group1."'";
}
$result1=mysqli_query($link,$sql1);
$list1=mysqli_fetch_array($result1);
$newstotal=$list1[total];
//指定一頁要瀏覽多少訊息
$newsview=5;
//計算總頁數
$newstotalpage=ceil($newstotal/$newsview);
if($newstotalpage==0){
$newstotalpage=1;
}
//計算每一頁的第一筆資料位置,無關資料庫資流水號
$readnewsstart=($newsview*($newspage1-1));
//讀取資料
if($group1==1){
$sql2="select news_ID,username,releasedate,releasetime,invaliddate,invalidtime,newsgroup,newstitle from labnews order by news_ID desc limit ".$readnewsstart.",".$newsview."";
}else{
$sql2="select news_ID,username,releasedate,releasetime,invaliddate,invalidtime,newsgroup,newstitle from labnews where newsgroup='".$group1."' order by news_ID desc limit ".$readnewsstart.",".$newsview."";
}
$result2=mysqli_query($link,$sql2);
//顯示資料
?>
mysqli_free_result($result1);
mysqli_free_result($result2);
mysqli_free_result($result3);
?>