Php simple page jump function implementation code _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Tags php foreach
Php code for simple page jump. Not to mention, copy the code directly. the code is as follows: connect to the database to query the mysql_connect (localhost, username, userpwd) ordie (database connection failure. mysql_error (); mysql_s is not much to say, directly add the code

The code is as follows:


// Query the connected database
Mysql_connect ('localhost', 'username', 'userpwd') or die ("database connection failed". mysql_error ());
Mysql_select_db ('database name ');
Mysql_query ('set names utf8 ');
$ Sql1 = "select * from user ";
$ Query1 = mysql_query ($ sql1 );
$ Count = array ();
While ($ row = mysql_fetch_assoc ($ query1 )){
$ Count [] = $ row;
}
$ Totalnews = count ($ count );
// Determine the page
If ($ _ GET ['Page']) {
$ Page = $ _ GET ['Page'];
} Else {
$ Page = 1;
}
$ Start = ($ page-1) * $ newnum;
$ SQL = "select * from user limit $ start, $ newnum ";
$ Query = mysql_query ($ SQL );
$ Ret = array ();
While ($ row = mysql_fetch_assoc ($ query )){
$ Ret [] = $ row;
}
?>
// Table style















$ Value) {?> // Page jump
Delete | modify
Homepage> Previous Page / "> Next Page"> Last Page


The following code links to the database: // query mysql_connect ('localhost', 'username', 'userpwd') or die ("database link failed ". mysql_error (); mysql_s...

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.