PHP programming problems

Source: Internet
Author: User
PHP programming problems a table in the database has 10 messages. if you want to display them by page, it is such a program: & lt ;? Phpinclude (& quot; conn. php & quot;); connect to the database $ pagesize5; set the number of messages displayed per page $ url $ _ SERVER [& quot; REQUEST_URI & quot;]; to get the current address. And use REQUEST_URL to make it $ u PHP programming problem
There are 10 messages in a table in the database. to display the messages by page, it is such a program:
Include ("conn. php"); // connect to the database
$ Pagesize = 5; // you can specify the number of messages displayed on each page.
$ Url = $ _ SERVER ["REQUEST_URI"]; // Obtain the current address. And use REQUEST_URL
$ Url = parse_url ($ url); // use the parse_url function: parses the url to convert the url into an array.
$ Url = $ url [path]; // Obtain the parsed path. Because there will be many keywords after parsing, such as scheme, host, user, pass, etc .. Call the key method in the array: $ url [key];


$ Numq = mysql_query ("SELECT * FROM 'test" '); // query the database information
$ Num = mysql_num_rows ($ numq); // display the total number of rows using the mysql_num_rows (function name) function ";

If ($ _ GET [page]) {
$ Pageval = $ _ GET [page];
$ Page = ($ pageval-1) * $ pagesize;
$ Page. = ',';
}
If ($ num> $ pagesize ){
If ($ pageval <= 1) $ pageval = 1;
Echo "$ num total ".
"Next page of the previous page ";
}


Echo $ SQL = "SELECT * FROM 'test' limit $ page $ pagesize ";
$ Query = mysql_query ($ SQL );
While ($ row = mysql_fetch_array ($ query )){

Echo" ". $ Row [name]." | ". $ row [sex];

}
?>


Why does $ _ GET [page] appear? Do you need to define this ??? For guidance, the mysteries of this sentence ..

------ Solution --------------------
No variable $ _ page is displayed.
If you are talking about $ page, $ page = ($ pageval-1) * $ pagesize; is the initialization of $ 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.