On the same page, I have two tables that need to be paged. when I instantiate the same paging class, a paging php Data problem occurs.
I have two tables on the same page, all requiring pagination. I have a paging class, and both tables instantiate this class. However, after turning pages, there is a problem and no data, why?
I instantiate it like this:
In the first table:
$my_page1=new PageClass($total1,20,$_GET['page'],'?account='.$_SESSION['account'].'&act=wyxx&page={page}');
In the second table:
$my_page2=new PageClass($total2,20,$_GET['page'],'?account='.$_SESSION['account'].'&act=blnr&page={page}');
The paging class is like this:
Class PageClass {private $ myde_count; // total number of records public $ myde_size; // number of records per page private $ myde_page; // The current page private $ myde_page_count; // total page size private $ page_url; // page urlprivate $ page_ I; // start page private $ page_ub; // end page public $ page_limit; function _ construct ($ myde_count = 0, $ myde_size = 1, $ myde_page = 1, $ page_url) // Constructor {$ this-> myde_count = $ this-> numeric ($ myde_count ); $ this-> myde_size = $ this-> numeric ($ myde_size); $ this-> myde_pag E = $ this-> numeric ($ myde_page); $ this-> page_limit = ($ this-> myde_page * $ this-> myde_size)-$ this-> myde_size; // start record of the next page $ this-> page_url = $ page_url; // connection address if ($ this-> myde_page <1) $ this-> myde_page = 1; // when the current page is smaller than 1, the value is assigned to 1 if ($ this-> myde_count <0) $ this-> myde_page = 0; $ this-> myde_page_count = ceil ($ this-> myde_count/$ this-> myde_size); // The total number of pages if ($ this-> myde_page_count <1) $ this-> myde_page_count = 1; if ($ this-> myde _ Page> $ this-> myde_page_count) $ this-> myde_page = $ this-> myde_page_count; // $ this-> page_ I = $ this-> myde_page-2; $ this-> page_ I = $ this-> myde_page-2; $ this-> page_ub = $ this-> myde_page + 2; // $ this-> page_ub = $ this-> myde_page + 2; if ($ this-> page_ I <1) $ this-> page_ I = 1; if ($ this-> page_ub> $ this-> myde_page_count) {$ this-> page_ub = $ this-> myde_page_count;} private function numeric ($ id) // determine whether it is a number {if (strlen ($ id) {if (! Ereg ("^ [0-9] + $", $ id) $ id = 1;} else {$ id = 1;} return $ id ;} private function page_replace ($ page) // address replace {return str_replace ("{page}", $ page, $ this-> page_url);} private function myde_home () // homepage {if ($ this-> myde_page! = 1) {return"Page_replace (1). "\" title = \ "homepage \"> homepage\ N ";} else {return"
Homepage\ N ";}} private function myde_prev () // Previous Page {if ($ this-> myde_page! = 1) {return"
Page_replace ($ this-> myde_page-1). "\" title = \ "previous page \"> Previous Page\ N ";} else {return"
Previous Page\ N ";}} private function myde_next () // Next Page {if ($ this-> myde_page! = $ This-> myde_page_count) {return"
Page_replace ($ this-> myde_page + 1). "\" title = \ "next page \"> Next page\ N ";} else {return"
Next page\ N ";}} private function myde_last () // The last page {if ($ this-> myde_page! = $ This-> myde_page_count) {return"
Page_replace ($ this-> myde_page_count). "\" title = \ "Last Page \"> Last Page\ N ";} else {return"
Last page\ N ";}} function myde_write ($ id = 'page') // output {$ str ="
\ N
\ N "; $ str. ="
- Total Record: ". $ this-> myde_count ."
\ N "; $ str. ="
- ". $ This-> myde_page."/". $ this-> myde_page_count ."
\ N "; $ str. = $ this-> myde_home (); $ str. = $ this-> myde_prev (); for ($ page_for_ I = $ this-> page_ I; $ page_for_ I <= $ this-> page_ub; $ page_for_ I ++) {if ($ this-> myde_page = $ page_for_ I) {$ str. ="
- ". $ Page_for_ I ."
\ N ";} else {$ str. ="
- Page_replace ($ page_for_ I). "\" title = \ "no.". $ page_for_ I. "Page \"> "; $ str. = $ page_for_ I ."
\ N ";}}$ str. = $ this-> myde_next (); $ str. = $ this-> myde_last (); $ str. ="
- Myde_page. "\" "; $ str. = "onmouseover = \" javascript: this. value = ''; this. focus (); \ "onkeydown = \" javascript: if (event. keyCode = 13) {location = '"; $ str. = $ this-> page_replace ("'+ this. value + '"). "'; return false ;}\" "; $ str. = "title = \" enter the page number you want to arrive at, and press enter! \ "/>
\ N "; $ str. ="
"; Return $ str ;}/ * --------------------------- instance ------------------------------ * $ page = new PageClass (, 5, $ _ GET ['Page'], '? Page = {page} '); // used for dynamic $ page = new pageclass(1000,5, 1__get1_'page'},'list-{page}.html'); // used for static or pseudo static $ page-> myde_write (); // Display */
Reply to discussion (solution)
Maybe the $ _ GET ['Page'] you GET should use two,
$ _ GET ['page1 '], $ _ GET ['page2']
Print the parameter and check it out ..
Pagination with AJAX
Generally, two pages are rarely seen on the page. to implement this function, use ajax paging.
Save the parameters to be transferred during page turning. When paging is implemented, it is not possible to instantiate the class and call this stored parameter.
The parameters on both pages are $ _ GET ['Page']. how can php identify them! Php makes proper judgment in the background and then uses the paging class.