No JS, full php process-oriented data paging implementation code _ PHP Tutorial

Source: Internet
Author: User
Without JS, php fully implements code for process data paging. Copy the code as follows :? Session set on the php login page. if the session contains name, session_start (); $ name $ _ SESSION [name]; if (empty ($ name) {header (Location: The code is as follows:


// The session set on the login page. when the session contains the name
// Session_start ();
// $ Name = $ _ SESSION ['name'];
// If (empty ($ name )){
// Header ("Location: error. php ");
// Exit ();
//}
// Process-oriented, data paging
If (false! = ($ Mysql = mysql_connect ('Local mysql', 'MySQL username', 'MySQL password '))){
Mysql_query ('set names utf8', $ mysql); // sets the encoding in the database.
Mysql_select_db ("database", $ mysql );
} Else {
Die ("connection failed ");
}


$ PageSize = 10; // Number of Entries displayed on the page
$ RowCount = 0; // The total number of data records, obtained from the database

$ SqlCount = 'SELECT count (id) from employee ';
$ Res1 = mysql_query ($ sqlCount, $ mysql );

// Retrieve the number of data entries
If (false! = ($ Row = mysql_fetch_row ($ res1 ))){
$ RowCount = $ row [0];
}

// The total number of pages, calculated
$ PageCount = 0;
$ PageCount = ceil ($ rowCount/$ pageSize );

// Obtain the current page
If (! Isset ($ _ GET ['pagenow']) {// if get/post is empty, the default value is 1.
$ PageNow = 1; // Current page number
} Elseif (false! = Is_numeric ($ _ GET ['pagenow']) & $ _ GET ['pagenow'] <= $ pageCount ){
$ PageNow = $ _ GET ['pagenow'];
} Else {
Header ("Location: ../Error/error. php ");
Exit ();
}
// Print the paging data
Echo"

";
Echo"








";Echo" ";$ SqList = "select id, name, age, sex, birthday from employee limit". ($ pageNow-1) * $ pageSize. ",". $ pageSize;$ Res2 = mysql_query ($ sqList, $ mysql );While (false! = ($ Row = mysql_fetch_assoc ($ res2 ))){Echo" ";}Echo"
Id Name Age Sex Birthday Edit employee Delete an employee
{$ Row ['id']} {$ Row ['name']} {$ Row ['age']} {$ Row ['sex']} {$ Row ['birthday']} Edit Delete
";
// Control the number of pages displayed in the form
Echo "";
Echo"

";
?>

The http://www.bkjia.com/PHPjc/325919.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/325919.htmlTechArticle code is as follows :? Php // The session set on the login page. When name exists in the session, // session_start (); // $ name = $ _ SESSION ['name']; // if (empty ($ name) {// header ("Location :...

Related Article

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.