用ODBC的分页显示

<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<?php


$pagesize = 3;//设置每页显示数目

//计算总记录数
$rs_num = "select count(*) as id from table";
$rs_num = ODBC_exec($conn_id,$rs_num);
$rs_num = ODBC_result($rs_num,"id");

//计算总页数
$pagecount = $rs_num / $pagesize;
$pagecount1 = intval($pagecount);//将总页数取整
$compare = $pagecount - $pagecount1;
switch ($compare){
case "0":
$pagecount = $pagecount1;//总页数
break;
default :
$pagecount1++;
$pagecount = $pagecount1;//总页数
break;
};
if ($pagecount == 0)$pagecount++;


$fpages = $pages-1;
$bpages = $pages+1;



?>
<table>
<tr>
<td>
共<?php echo $pagecount ?>页  
<?php if($pages != 1)echo "<a href=show.php3?pages=1>";?>首页<?php if($pages != 1)echo "</a>"; ?>  
<?php if($pages != 1)echo "<a href=show.php3?pages=".$fpages.">"; ?>前页<?php if($pages != 1)echo "</a>"; ?>  
<?php if($pages != $pagecount)echo "<a href=show.php3?pages=".$bpages.">"; ?>后页<?php if($pages != $pagecount)echo "</a>"; ?> <?php if($pages != $pagecount)echo "<a href=show.php3?pages=".$pagecount.">"; ?>
尾页<?php if($pages != $pagecount)echo "</a>"; ?>
</td>
</tr></table>
<?php
$firstshow = ($pages-1)*$pagesize+1;//确定每页的第一条记录

//找出第一条记录的记录号
$query_string = "SELECT * FROM table Order By id DESC";
$query_string = ODBC_exec($conn_id,$query_string);
ODBC_fetch_into($query_string,$firstshow,&$idarea);
$idsql = $idarea[0];

//定位查找
if ($pages == $pagecount) {
$rs = "SELECT * FROM table where id <= '".$idsql."' Order By id DESC";
}else{
$rs = "SELECT Top ".$pagesize." * FROM table where id <= '".$idsql."' Order By id DESC";
};

$rs = ODBC_exec($conn_id,$rs);

//显示记录
while(ODBC_fetch_row($rs)){



};
?>

<?php
//关闭连接
ODBC_close($conn_id);
?>


【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】    
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
阅读更多
文章标签: table string query
个人分类: 网络技术
想对作者说点什么? 我来说一句

用PHP实现分页显示

2014年08月25日 94KB 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭