線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:2534
推到 Plurk!
推到 Facebook!

PHP 切換下一頁問題 所查詢資料無法顯示

缺席
tzuhsun
一般會員


發表:7
回覆:8
積分:3
註冊:2007-03-25

發送簡訊給我
#1 引用回覆 回覆 發表時間:2007-11-03 21:44:32 IP:125.229.xxx.xxx 訂閱
以下是小弟寫的程式碼
在第一頁顯示正常
可是切換下一頁的時候就會沒資料了!

[code php]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><br /><head><br /><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><br /><title>無標題文件</title><br /><style type="text/css"><br /><!--
body {
background-color: #F0F0F0;
}
.style6 {color: #0033CC;
font-weight: bold;
}
.style7 {color: #669900}
-->
</style><br /></head><br />
<body><br />
<!--
function CreateWindow(url){
msgWindow=window.open(url,"displayWindow","toolbar=no,width=600,
height=400, directories=no, status=no, scrollbars=yes, resize=no,
menubar=no");
}
//-->

<?php
if(!empty($_POST['Graduate']) or !empty($_POST['Class']) or !empty($_POST['SchSys']))
{
include_once( "cmnFunc.inc" );
$link = toConnectDB();

$Graduate = $_POST['Graduate'];
$Class = $_POST['Class'];
$SchSys = $_POST['SchSys'];

$sql = "select * from account where Class like '%$Class%' and Graduate like '%$Graduate%' and SchSys like '%$SchSys%' ;";
$result = mysql_query($sql,$link);

if (mysql_num_rows($result) ==0)
{
?>








查詢結果
查無此資料


<?php
}//end if
else
{
?>












<?php

$sql = "select * from account where Class like '%$Class%' and Graduate like '%$Graduate%' and SchSys like '%$SchSys%' ;";
$result = mysql_query($sql,$link);

//取得記錄數
$total_records=mysql_num_rows($result);

$last=intval(($total_records-1)/5) 1; //intval()將變數$var轉換為整數;ex: intval(0.3) = 0
if($page<1) $page=1;
$start_num=5*($page-1);
if($page>$last) $page=$last;
//執行SQL命令 - 取出資料

$str="select * from account where Class like '%$Class%' and Graduate
like '%$Graduate%' and SchSys like '%$SchSys%' LIMIT $start_num,5";
$result=mysql_query($str,$link);
if(!$result) die("執行SQL命令 - 取出資料失敗");

if($total_records>0){
mysql_data_seek($result,0);
for($i=1;$i<=5;$i ) {
if($row=mysql_fetch_array($result)){
?>







<?php
}//if($row=mysql_fetch_array($result))
} // for
} // if($total_records>0)
?>
查詢結果
姓名
班級
學制
畢業學年
href="//"
"CreateWindow('A_content.php?relation=<?php echo
$row["SN"]?>')"><?php echo
$row['Name'];?>
<?php echo $row['Class'];?>
<?php echo $row['SchSys'];?>
<?php echo $row['Graduate'];?>



<form name="form1" method="post" action="1.php"><br />

<input type="submit" name="Submit" value="返回"><br />

</form><br />
<form name="form1" method="GET" action="A2.php"><br />

<?php
if ($page<>1) {
echo "第一頁 ";
echo "上一頁 ";
}
if ($page<>$last) {
echo "下一頁 ";
echo "最後一頁 ";
}
?>
頁次:<?php echo $page;?>/<?php echo $last;?>

</form><br />
<?php
}
}
?>
</body><br /></html><br />[/code]
編輯記錄
tzuhsun 重新編輯於 2007-11-03 21:45:03, 註解 無‧
yckuo 重新編輯於 2007-11-03 23:52:41, 註解 無‧
系統時間:2024-05-04 22:58:59
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!