php分页实现的有关问题
程序员文章站
2022-05-05 15:49:07
...
php分页实现的问题
在虚拟主机上可以实现自动分页,但在本地却不行?
具体代码
显示页
include("pageconfig.php"); $mysql_server_name = 'localhost'; $mysql_username = 'wind'; $mysql_password = '2008'; $mysql_database = 'wind'; mysql_connect($mysql_server_name,$mysql_username,$mysql_password); mysql_select_db($mysql_database);$counter = mysql_query ("select count(*) as counte from word"); $myrow=mysql_fetch_array($counter); $total=$myrow['counte']; $firstcount=1;$displaypg=10;pageft($total,10); $conn = mysql_connect($mysql_server_name,$mysql_username,$mysql_password); mysql_select_db($mysql_database);$result = mysql_query ("select * from word limit $firstcount,$displaypg "); echo(" "); while($myrow = mysql_fetch_row($result)){ echo("
");?> =$pagenav;?>
pageconfig.php代码: if(!function_exists(pageft)){ function pageft($totle,$displaypg=20,$url=''){ global $page,$firstcount,$pagenav,$_SERVER; $GLOBALS["displaypg"]=$displaypg; if(!$page) $page=1; if(!$url){ $url=$_SERVER["REQUEST_URI"];} $parse_url=parse_url($url); $url_query=$parse_url["query"]; if($url_query){ $url_query=ereg_replace("(^|&)page=$page","",$url_query); $url=str_replace($parse_url["query"],$url_query,$url); if($url_query) $url.="&page"; else $url.="page"; }else { $url.="?page"; } $lastpg=ceil($totle/$displaypg); $page=min($lastpg,$page); $prepg=$page-1; //上一页 $nextpg=($page==$lastpg ? 0 : $page+1); //下一页 $firstcount=($page-1)*$displaypg; $pagenav="显示第 ".($totle?($firstcount+1):0)."-".min($firstcount+$displaypg,$totle)." 条记录,共 $totle 条记录"; if($lastpg首页 "; if($prepg) $pagenav.=" 前页 "; else $pagenav.=" 前页 "; if($nextpg) $pagenav.=" 后页 "; else $pagenav.=" 后页 "; $pagenav.=" 尾页 "; $pagenav.=" 到第 页,共 $lastpg 页"; } } ?>
在虚拟主机上可以实现自动分页,但在本地却不行?
具体代码
显示页
相关文章
相关视频
上一篇: 如何将远程服务器MYSQL数据库导出导入_MySQL
下一篇: 如何自动挂机2048游戏