Home  >  Article  >  Backend Development  >  php分页实现的有关问题

php分页实现的有关问题

WBOY
WBOYOriginal
2016-06-13 13:25:14825browse

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(""); for ($j=0;$j"); printf("%s",$myrow[$j]);//输出标题 echo(""); } echo(""); } 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 页"; } } ?>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn