For PHP paging problems, please kindly advise

Source: Internet
Author: User
For PHP paging problems, please kindly advise & lt; html & gt; & nbsp; & lt; head & gt; & nbsp; & lt; meta & nbsp; charset = "UTF-8" & gt; & lt;/head & gt; & nbsp; & lt; script & nbsp; type = "text PHP paging problem.

 
 

 
Script

 
Function aurl (I ){
Var url = window. location. href;
If (url. indexOf ('? ')> 0 ){
Url = url. substring (0, url. indexOf ('? '));
}
Url = url + "? Page = "+ I;
Document. getElementById ("documentForm"). action = url;
Document. getElementById ("insu"). click ();
}
Script

 

$ Key = $ _ POST ["key"];
If ($ key = "")
{
Echo "enter search criteria ";
Return;
}
// Obtain the page number
$ Page = @ $ _ GET ['Page'];
// Define the number of items displayed on each page
$ Page_size = 10;
// When the page number parameter is blank, set the page number to 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 ); // passing parameters
$ Ret = $ client-> NewsSearch ($ param); // execute the method for obtaining news
// 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 ';
}
// Total number of pages
$ TotalPage = ceil ($ item-> NewsCount)/$ page_size );
// Previous page link
$ Prev = $ page-1;
If ($ Prev <1)
{
$ Prev = 1;
}
// Next page
$ Next = $ page + 1;
If ($ Next> $ totalPage)
{
$ Next = $ totalPage;
}
// Output the previous page link
If ($ page <> 1)
{
Echo 'first ';
Echo 'prev ';
}
Else
{
Echo 'first ';
Echo 'prev ';
}
// Page number link
// Number of displayed numbers
$ PageNumber = 5;
// Page number algorithm
$ Pagebegin = $ page-$ pageNumber;
If ($ page = 1)
{
$ Pageend = $ pageNumber;
}
Else
{
$ Pageend = $ page + $ pageNumber;
}
If ($ pagebegin <= 0)
{
$ Pagebegin = 1;
}
If ($ pageend> $ totalPage)
{
$ Pageend = $ totalPage;
}
// Forward $ pageNumber rows at a time
If ($ page> $ pageNumber)
{
Echo '<';
}
// Output the dynamically generated page number link
For ($ I = $ pagebegin; $ I <= $ pageend; $ I ++)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.