Home > Backend Development > PHP Tutorial > PHP分页有关问题,求大神指导

PHP分页有关问题,求大神指导

WBOY
Release: 2016-06-13 12:46:54
Original
849 people have browsed it

PHP分页问题,求大神指导

<br>
 <br>
 <br>
<meta><br>
 <br>
<script></script><br>
<script><br />
 <br />
function aurl(i){<br />
 var url = window.location.href;<br />
 if(url.indexOf('?')>0){<br />
   url=url.substring(0,url.indexOf('?')) ;<br />
} <br />
url=url+"?page="+i;<br />
 document.getElementById("documentForm").action=url;<br />
 document.getElementById("insu").click();<br />
  }<br />
</script><br>
 <br>
Copy after login
 

 输入关键字:
  

 

  

 
 

$key = $_POST["key"]; 
if($key=="")
{
  echo "请输入搜索条件";
return;
}
//取得页码
$page = @$_GET['page'];
//定义每页显示信息条数
$page_size = 10;
//当页码参数为空时,将页码设为1
if ($page == "")
{
    $page = 1;
}
$wsdl="http://pica.chalwin.com/service/JsAccessWebService.asmx?wsdl";
$client = new SoapClient($wsdl);
$param = array('NodeId'=>'1','key'=>$key,'pageIndex'=>$page,'pageSize'=>$page_size);//传参
$ret = $client->NewsSearch($param);//执行获取新闻的方法
//print_r ($ret);
if(isset($ret)&&$ret)
{
 foreach($ret->NewsSearchResult->InheritanceNews as $item) 
{   
echo "\n\n";
echo "\n";
echo "";
}
}
else
{
echo 'no user';
}
//总页数
$totalPage = ceil(($item->NewsCount)/$page_size);
//上一页链接
$Prev = $page - 1;
if ($Prev  {
$Prev = 1;
}
//下一页链接
$Next = $page + 1;
if ($Next > $totalPage)
{
$Next = $totalPage;
}
//输出上一页链接
if ($page  1)
{
echo 'First ';
echo 'Prev';
}
else
{
echo 'First';
echo 'Prev';
}
//页码数字链接
//显示的数字个数
$pageNumber = 5;
//页码数算法
$pagebegin = $page - $pageNumber;
if ($page == 1)
{
$pageend = $pageNumber;
}
else
{
$pageend = $page + $pageNumber;
}
if ($pagebegin  {
$pagebegin = 1;
}
if ($pageend > $totalPage)
{
$pageend = $totalPage;
}
//一次向前翻$pageNumber行
if ($page > $pageNumber)
{
echo '';
}
//输出动态生成的页码链接
for ($i = $pagebegin; $i 
$item->Title
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template