Php, mixed editing, data paging

Source: Internet
Author: User
Php, hybrid editing, and data paging to connect to the database

$ Conn = mysql_connect ('localhost', 'root', 'root') or die ('errorcode: '. mysql_errno ().', Error: '. mysql_error ());

Mysql_select_db ('Company') or die ('errorcode: '. mysql_errno ().', Error: '. mysql_error ());

?>

Paging of mixed data





Test page


Include 'Conn. php ';

$ Pagesize = 10;
Mysql_query ("set names utf8 ");
$ SQL = "SELECT count (*) cnt FROM com_info"; // Retrieve the total number of records
$ R = mysql_query ($ SQL) or die ('error code: '. mysql_errno ().', error: '. mysql_error ());

$ Row = mysql_fetch_assoc ($ r );
$ Total = $ row ['cnt ']; // The total number of records.

$ Total_pages = ceil (intval ($ total)/$ pagesize); // total number of pages

$ Pn = isset ($ _ GET ['Page'])? Intval ($ _ GET ['Page']): 1;
$ Pn <1 & $ pn = 1;
$ Pn >=$ total_pages & $ pn = $ total_pages;

$ Offset = ($ pn-1) * $ pagesize;
$ SQL = "SELECT com, com_name FROM com_info LIMIT {$ offset}, {$ pagesize }";
$ R = mysql_query ($ SQL) or die ('error code: '. mysql_errno ().', error: '. mysql_error ());

?>








While ($ row = mysql_fetch_assoc ($ r )){?> }?>
No. Company name


Homepage
For ($ I = 1; $ I <= $ total_pages; $ I ++ ){
?>
"> Page
}

?>
"> Last Page



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.