Find a specific php + mysql page-do not search for it online

Source: Internet
Author: User
Find a specific php + mysql page-do not search for it on the internet. 1. click page a to display it on page B.
II. code displayed by page
3. features of the last page on the home page 1 2 3 4 5
4. after pages are turned over, the normal display of the content is that the data of the database can be displayed normally when the pages on the top and bottom pages are clicked (parameters transmitted from page a are not lost ),


Reply to discussion (solution)

Class page {private $ _ page_num; // total number of pages private $ _ page_size = 10; // Number of pages per page private $ _ page_url; // url link private $ _ limit; // limit1private $ _ page_total; // The total number of pages in private $ _ page; // The value of the paginated pages is private $ _ list_size = 10; // This is the second paging method. the number of lines displayed is private $ _ page_sort = 3; // The distance between the two sides of the page is public function _ construct ($ _ total, $ _ pagesize, $ _ list_size) {$ this-> _ page_size =$ _ pagesize; $ this-> _ page_total =$ _ total; $ this-> _ list_size = $ _ list_size; $ this-> _ page_num = r Ound ($ this-> _ page_total/$ this-> _ page_size); $ this-> _ page = $ this-> getnum (); $ this-> _ limit = "limit ". $ this-> _ page * $ this-> _ page_size. ",". $ this-> _ page_total =$ _ total; $ this-> _ page_url = $ this-> seturl ();} /*** get the current page ** Enter description here... */private function getnum () {if (isset ($ _ GET ['Page']) {if (is_numeric ($ _ GET ['Page']) {if ($ _ GET ['Page']> 0) {if (ceil ($ _ GET ['Page'])> = 1 & ceil ($ _ GET ['Page']) <= $ this-> _ page_nu M) {return ceil ($ _ GET ['Page']);} elseif (ceil ($ _ GET ['Page'])> $ this-> _ page_num) {return $ this-> _ page_num;} else {return 1 ;}} else {return 1 ;}} else {return 1 ;}} /*** conversion link * Enter description here... */private function seturl () {$ _ url = $ _ SERVER ['request _ URI ']; // Obtain the REQUEST address $ _ par = parse_url ($ _ url ); // Parse urlif (isset ($ _ par ['query']) {// determine whether there is a format like aa = bb $ _ url = parse_str ($ _ par ['query'], $ _ query ); // Reconstruct urlunset ($ _ query ['Page']); $ _ Url = $ _ par ['path']. '? '. Http_build_query ($ _ query);} else {$ _ url = $ _ url .'? ';} Return $ _ url;} public function limit () {return $ this-> _ limit;} public function pagenum () {return $ this-> _ page_num ;} /* public function page () {return $ this-> _ page;} public function pageurl () {return $ this-> _ page_url;} */private function first () {return "_ page_url. "& page = 1> homepage";} private function end () {return "_ page_url. "& page = ". $ this-> _ page_num. "> last page";} private function prev () {if ($ this-> _ page> 1) {return "_ page_url. "& page = ". ($ this-> _ page-1 ). "> Previous page";} else {return 'previous page ';} public function next () {if ($ this-> _ page <$ this-> _ page_num) {return "_ page_url. "& page = ". ($ this-> _ page + 1 ). "> Next page";} else {return 'next page ';} private function pagelist_1 () {$ _ page = ''; for ($ I = 1; $ I <= $ this-> _ page_num; $ I ++) {$ _ page. = "_ page_url. "& page = ". $ I. "> ". $ I. "";} return $ _ page;} private function pagelist_2 () {$ _ page = ''; $ _ page_start = floor ($ this-> _ page/$ this-> _ list_size ); $ usenum = $ this-> check ($ _ page_start * $ this-> _ list_size + 10), $ this-> _ page_num ); for ($ I = $ _ page_start * $ this-> _ list_size + 1; $ I <= $ usenum; $ I ++) {$ _ page. = "_ page_url. "& page = ". $ I. "> ". $ I. "";} return $ _ page;} private function pagelist_3 () {$ page = ''; for ($ I = $ this-> _ page-$ this-> _ page_sort; $ I <= $ this-> _ page-1; $ I ++) {if ($ I <1) continue; $ page. = "_ page_url. "& page = ". $ I. "> ". $ I. "". '';} $ page. = "_ page_url. "& page = ". $ this-> _ page. "> ". $ this-> _ page. "". ''; for ($ I = $ this-> _ page + 1; $ I <= $ this-> _ page + $ this-> _ page_sort; $ I ++) {if ($ I >$ this-> _ page_num) break; $ page. = "_ page_url. "& page = ". $ I. "> ". $ I. "". '';} return $ page;}/*** uncorrected page List * Enter description here... */private function pagelist_4 () {$ page = ''; for ($ I = $ this-> _ page-$ this-> _ page_sort; $ I <= $ this-> _ page-1; $ I ++) {if ($ I <1) continue; $ page. = "_ page_url. "& page = ". $ I. "> ". $ I. "". '';} $ page. = "_ page_url. "& page = ". $ this-> _ page. "> ". $ this-> _ page. "". ''; for ($ I = $ this-> _ page + 1; $ I <= $ this-> _ page + $ this-> _ page_sort; $ I ++) {if ($ I >$ this-> _ page_num) break; $ page. = "_ page_url. "& page = ". $ I. "> ". $ I. "". '';} // + 1 and-1 in order to exclude the values displayed on the previous page, otherwise they will repeat if ($ this-> _ page> ($ this-> _ page_sort + 1) & $ this-> _ page <($ this-> _ page_num-$ this-> _ page_sort) {$ page = "_ page_url. "& page = ". ($ this-> _ page-$ this-> _ page_sort * 2-1 ). ">... ". $ page. "_ page_url. "& page = ". ($ this-> _ page + $ this-> _ page_sort * 2 + 1 ). ">... ";}return $ page;} private function check ($ num1, $ num2) {if ($ num1> $ num2) {return $ num2 ;} else {return $ num1 ;}} public function showpage ($ _ type) {$ _ page = ''; $ _ page. = $ this-> first (); // Home switch ($ _ type) {case '1': $ _ page. = $ this-> pagelist_1 (); // original page List break; case '2': $ _ page. = $ this-> pagelist_2 (); // original page List break; case '3': $ _ page. = $ this-> pagelist_3 (); // original page List break; case '4': $ _ page. = $ this-> pagelist_4 (); // original page List break; default: $ _ page. = $ this-> pagelist_3 (); // Default original page List} $ _ page. = $ this-> end (); // end page $ _ page. = $ this-> prev (); // Previous page $ _ page. = $ this-> next (); // next page return $ _ page; }}// $ page = new page (, 10 ); // echo $ page-> showpage ('4 ');

This seems to be usable.

Sorry, I am a beginner and I am not very familiar with classes. now I click (such as household appliances) to display the following content:
Current location | homepage | household electrical appliances
Content 1
Content 2
Content 3
2 pages, 1st pages, 5 records, next page, and last page
Click next to show only:
Current location | homepage | class
8 pages, 2nd pages, 30 Records, home pages, previous pages, and last pages

I don't know much about it, but I found other methods.

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.