(Urgent) questions about pagination of PHP + MYSQL Query Results

Source: Internet
Author: User
Tags form post
(Urgent !!) The query results of PHP + MYSQL are displayed on the page with the issue include_once (& quot ;. config. php & quot;); db_connect (); get the current page if (isset ($ _ POST [page]) determine whether the value of the following form post is {$ page $ _ POST [page];} elseif (isset ($ _ GET (Urgent !!) Pagination of PHP + MYSQL Query Results
Include_once ("./config. php ");
Db_connect ();
// Obtain the current page number
If (isset ($ _ POST ['Page']) // you can determine whether the values of the following form post exist.
{
$ Page = $ _ POST ['Page'];
}
Else if (isset ($ _ GET ['Page']) // you can determine whether a get value exists.
{
$ Page = intval ($ _ GET ['Page']);
}
Else
{
$ Page = 1;
}
// Number of pages per page
$ Page_size = 10;
$ Devicename = $ _ POST ["textname"];

If ($ _ POST [Submit]! = "")
{
$ SQL = "select count (*) as amount from labdeviceinfo where DeviceName = '$ devicename '";
}
Else
{
$ SQL = "select count (*) as amount from labdeviceinfo ";
}

$ Result = mysql_query ($ SQL );
$ Row = mysql_fetch_row ($ result );
$ Amount = $ row [0]; // obtain the total data volume
// Count the total number of pages
If ($ amount)
{
If ($ amount <$ page_size) // if the total data volume is less than $ PageSize, there is only one page
{
$ Page_count = 1;
}
If ($ amount % $ page_size) // Retrieve the total data volume divided by the remainder of each page
{
$ Page_count = (int) ($ amount/$ page_size) + 1; // if there is a remainder, the number of pages equals the total data volume divided by the result of each page number and then adds one
}
Else
{
$ Page_count = $ amount/$ page_size; // if there is no remainder, the number of pages equals the total data volume divided by the result of each page
}
}
Else
{
$ Page_count = 0;
}
// Flip link
$ Page_string = '';
If ($ page = 1)
{
$ Page_string. = 'homepage | previous page | ';
}
Else
{
$ Page_string. = 'homepage | previous page | ';

}
If ($ page = $ page_count) | ($ page_count = 0 ))
{
$ Page_string. = 'next page | last page ';
}
Else
{
$ Page_string. = 'next page | last page ';
}
?>





















$ Server = $ _ SERVER ['php _ SELF '];$ Start = ($ page-1) * $ page_size;If ($ _ POST [Submit]! = "" | $ _ POST [textname]){$ Devicename = $ _ POST ["textname"];$ Sqlquery = "select * from labdeviceinfo where DeviceName = '$ devicename' limit $ start, $ page_size ";}Else{$ Sqlquery = "select * from labdeviceinfo limit $ start, $ page_size ";}$ Myresult = mysql_query ($ sqlquery );While ($ myrow = mysql_fetch_array ($ myresult )){?> ". $ Myrow [1].""." "." "." "." "." "." "." ";?>
". $ Myrow [2]."". $ Myrow [3]."". $ Myrow [4]."". $ Myrow [5]."". $ Myrow [6].""." Details "."






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.