PHP分页有关问题,求大神指导
时间:2021-07-01 10:21:17
帮助过:37人阅读
PHP分页问题,求大神指导
$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 "$item->Title | \n";
echo "
";
}
}
else
{
echo 'no user';
}
//总页数
$totalPage = ceil(($item->NewsCount)/$page_size);
//上一页链接
$Prev = $page - 1;
if ($Prev < 1)
{
$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 <= 0)
{
$pagebegin = 1;
}
if ($pageend > $totalPage)
{
$pageend = $totalPage;
}
//一次向前翻$pageNumber行
if ($page > $pageNumber)
{
echo '<<';
}
//输出动态生成的页码链接
for ($i = $pagebegin; $i <= $pageend; $i++)
人气教程排行