国产午夜男女爽爽爽爽爽_亚洲A∨无码一区二区一二区毛片_蜜桃tv在线二三区_天天摸一摸视频寡妇_国产欧美国产精品第二区_亚洲老司机在线凹凸福利网站_大痉挛中文字幕色视频_欧美日韩性爱第一页_亚洲高清无码在线一区二区_亚洲黄片视频免费看

php+mssql 分頁(yè)處理

2012-04-20 17:04:49

<tr><td><table border = "0" cellspacing=0 cellpadding=0 class="list" align="left" width = "100%">
<tr>
<td width="5%" class=list>No</td>
<td width="20%" class=list>Department Code</td>
<td width="20%" class=list>Department Name</td>
<td width="45%"class=list>Department Description</td>
<td width="10%" class=list>Action</td>
</tr>
<?php
require('connectDB.php');
$depcode = $_POST['departmentCode'];
//echo $depcode."<br>";
$depname = $_POST['departmentName'];
//echo $depname."<br>";
$depquery = "SELECT * FROM TBLDEPARTMENT WHERE 1>0 ";
if($depcode ){
$depquery .=" AND DEPTCODE = '{$depcode}' ";

}
if($depname ){
$depquery .=" AND DEPTNAME = '{$depname }' ";
}
// echo "sql---{$depquery}" ;
$ntt_result_info = MSSQL_QUERY($depquery);

 

/*分頁(yè)處理開(kāi)始*/

 

$ntt_row_counts=mssql_num_rows($ntt_result_info); //查詢(xún)出數(shù)據(jù)集的行數(shù)
if($ntt_row_counts!=0) //如果查詢(xún)出數(shù)據(jù)集不為空
{
$ntt_perpagerows=2; //設(shè)定每頁(yè)行數(shù)
$ntt_page = $_GET['page']; //當(dāng)前現(xiàn)實(shí)頁(yè)數(shù)
if(!$ntt_page||$ntt_page<1)
{
$ntt_page=1;
}
$ntt_max_page=ceil($ntt_row_counts/$ntt_perpagerows); //查詢(xún)出的數(shù)據(jù)集最多能分得頁(yè)數(shù)
//echo $row_counts;
$ntt_result_index=($ntt_page-1)*$ntt_perpagerows; //當(dāng)前頁(yè)要顯示的第一條數(shù)據(jù)的index
//echo "index---{$result_index}";
mssql_data_seek($ntt_result_info,$ntt_result_index);//設(shè)定在數(shù)據(jù)集的開(kāi)始index設(shè)定成當(dāng)前頁(yè)要顯示的第一條數(shù)據(jù)

$ntt_count=1; //計(jì)數(shù)器
while($ntt_row_info=mssql_fetch_array($ntt_result_info))//開(kāi)始從設(shè)定好的index開(kāi)始循環(huán)
{
if($ntt_count>$ntt_perpagerows)//將要輸出數(shù)據(jù)的行數(shù)大于每頁(yè)行數(shù)時(shí)跳出循環(huán)
{
break;
}

?>
<tr>
<td class='list_row' align = 'center' ><?php echo $ntt_perpagerows*($ntt_page-1)+$ntt_count; ?></td>
<td class='list_row' align = 'left' ><?php echo $ntt_row_info[DEPTCODE]; ?></td>
<td class='list_row' align = 'left' ><?php echo $ntt_row_info[DEPTNAME]; ?></td>
<td class='list_row' align = 'left' ><?php echo $ntt_row_info[DEPTDESC]; ?></td>
<td class='list_row'>
<a href='#' onclick=''>
<img src='/product_php/images/standard/Edit1.jpg' border='0'>
</a>
<a href='#' onclick=''>
<img src='/product_php/images/standard/delete.gif' border='0'>
</a>
</td>
</tr>
<?php
$ntt_count++; //計(jì)數(shù)器累加
}
}else{ //如果查詢(xún)出數(shù)據(jù)集為空
$ntt_page=1;
$ntt_max_page=0;
}
mssql_free_result($ntt_result_info);
mssql_close();
?>
</table>

</td></tr>
<tr>
<td align="right">
<input type="button" value="<<" onclick="document.all.departmentViewForm.action='DEPS02.php?page=1';document.all.departmentViewForm.submit(); " <?php if($ntt_page==1){echo "disabled";} ?> class='xyh_short_btn'>
<input type="button" value="<" onclick="document.all.departmentViewForm.action='DEPS02.php?page=<?php echo $ntt_page-1;?>';document.all.departmentViewForm.submit(); " <?php if($ntt_page==1){echo "disabled";} ?> class='xyh_short_btn'>
<input type="button" value=">" onclick="document.all.departmentViewForm.action='DEPS02.php?page=<?php echo $ntt_page+1;?>';document.all.departmentViewForm.submit(); " <?php if($ntt_page>=$ntt_max_page){echo "disabled";} ?> class='xyh_short_btn'>
<input type="button" value=">>" onclick="document.all.departmentViewForm.action='DEPS02.php?page=<?php echo $ntt_max_page; ?>';document.all.departmentViewForm.submit(); " <?php if($ntt_page>=$ntt_max_page){echo "disabled";} ?> class='xyh_short_btn'>
</td>
</tr>