php分页实现的问题
在虚拟主机上可以实现自动分页,但在本地却不行?
具体代码
显示页
<table width=600 border=0 align=center> <? 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("<table border=1;> "); while($myrow = mysql_fetch_row($result)) { echo("<tr>"); for ($j=0;$j<7;$j++) { echo("<td>"); printf("%s",$myrow[$j]);//输出标题 echo("</td>"); } echo("</tr>"); } echo("</table>"); ?> <td colspan=5 bgcolor=#CCCCCC><?=$pagenav;?></td> </tr> </table> 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="显示第 <B>".($totle?($firstcount+1):0)."</B>-<B>".min($firstcount+$displaypg,$totle)."</B> 条记录,共 $totle 条记录"; if($lastpg<=1) return false; $pagenav.=" <a href='$url=1'>首页</a> "; if($prepg) $pagenav.=" <a href='$url=$prepg'>前页</a> "; else $pagenav.=" 前页 "; if($nextpg) $pagenav.=" <a href='$url=$nextpg'>后页</a> "; else $pagenav.=" 后页 "; $pagenav.=" <a href='$url=$lastpg'>尾页</a> "; $pagenav.=" 到第 <select name='topage' size='1' onchange='window.location=\"$url=\"+this.value'>\n"; for($i=1;$i<=$lastpg;$i++){ if($i==$page) $pagenav.="<option value='$i' selected>$i</option>\n"; else $pagenav.="<option value='$i'>$i</option>\n"; } $pagenav.="</select> 页,共 $lastpg 页"; } } ?>
相关推荐
yifangs 2020-10-13
zyyjay 2020-11-09
xuebingnan 2020-11-05
samtrue 2020-11-22
stefan0 2020-11-22
songshijiazuaa 2020-09-24
hebiwtc 2020-09-18
天步 2020-09-17
83911535 2020-11-13
whatsyourname 2020-11-13
zhouyuqi 2020-11-10
Noneyes 2020-11-10
mathchao 2020-10-28
王志龙 2020-10-28
wwwsurfphpseocom 2020-10-28
diskingchuan 2020-10-23
savorTheFlavor 2020-10-23