PHP MSSQL 分页实例

网络编程 2021-07-05 09:10www.168986.cn编程入门
这篇文章主要介绍了PHP MSSQL可刷新分页实例,以及PHP+MSSQL通用分页公式,感兴趣的小伙伴们可以参考一下

本文实例为大家分享了PHP MSSQL可刷新分页实例,具体内容如下

<?php
/
 '页面说明
/

$link=mssql_connect("MYSQL2005","sa","123456") or die("db link error!".mssql_error());
mssql_select_db("edu_dzk",$link) or die("db open error!".mssql_error());
//mssql_query("set names 'utf8'");

$sqlstrcount="SELECT count(1) FROM reguser";

$page = $_GET["page"];

if(!is_numeric($page)){
 $page="1";
}

$pagesize="30";

//$sql=mysql_query($sqlstr);

//$totalnum=mysql_num_rows($sql);

$sql=mssql_query($sqlstrcount);

list($totalnum)=mssql_fetch_row($sql);

$pagecount=ceil($totalnum/$pagesize);

$offset=($page-1)$pagesize;

$sqlstr="Select  ".($pagesize)."  from reguser where id not in (select  ".(($page-1)$pagesize)." id from reguser order by id desc) order by id desc";

$sql=mssql_query($sqlstr);

$result="";
while($result=mssql_fetch_array($sql)){
 echo $result["id"].'<br>';
}

showpageinfo2($totalnum,$pagecount,$page,"&z=".$z);
mssql_Close($link);

function showpageinfo2($totalnum,$pagecount,$page,$filster)
{
 echo "共计: $totalnum 条记录,共 $pagecount 页,当前是第 $page 页 ";

 if($page!=1)
 {
 echo "<a href=?page=1$filster>首页</a> ";
 echo "<a href=?page=".($page-1)."$filster>上一页</a> ";
 }

 if($page<$pagecount)
 {
 echo "<a href=?page=".($page+1)."$filster>下一页</a> ";
 echo "<a href=?page=$pagecount$filster>尾页</a>&nbsp;&nbsp;";
 }

}

?>

狼蚁网站SEO优化为大家分享了PHP+MSSQL通用分页公式,供大家参考,具体内容如下

<?php
//phpinfo();
//$conn=mssql_connect('192.168.0.3','app','web')or die (mssql_get_last_message());
//if($conn)
//{
//?echo "suess";
/ 

Copyright © 2016-2025 www.168986.cn 狼蚁网络 版权所有 Power by