Why can't I flip my PHP pages to the next page? could you tell me how to define a class to output the following class attributes?
Include ("script/conn. php "); class Page {private $ page; // The current Page number private $ page_num; // The total number of data pages displayed. private $ page_size; // The number of data entries displayed on each page is private $ SQL; // The queried SQL statement is private $ limit; // The limit control statement after the query statement is private $ total_Num; // total number of records public function _ construct ($ SQL = '', $ page_size = 3) {$ result = mysql_query ($ SQL ); $ this-> total_Num = mysql_num_rows ($ result); $ this-> page_size = $ page_size; $ this-> page_num = ceil ($ this-> total_Num /$ Page_size); // calculate the total number of pages $ this-> SQL = $ SQL; $ temp = (isset ($ _ GET ["page"])? $ _ GET ["page"]: 1); // GET the current page $ this-> setpage ($ temp); $ this-> showpage (); $ this-> showFoot ();} private function showpage () {$ this-> limit = "LIMIT ". ($ this-> page-1) * $ this-> page_size ). ",". $ this-> page_size; // limit statement $ result = mysql_query ($ this-> SQL. $ this-> limit); if (! $ Result) {// Determine whether the result exists if ($ this-> page_num> 0) {// if it does not exist and the page number is greater than 0 echo "query error "."
";} Else {echo" no data "."
";}Return ;}$ cols = mysql_num_rows ($ result); while ($ row = mysql_fetch_array ($ result) {echo" "; echo"
";}} Private function setpage ($ page) {if ($ page <1) {$ page = 1;} else if ($ page >$ this-> page_num) {$ page = $ this-> page_num;} $ this-> page = $ page;} private function showFoot () {echo"
"; Echo" homepage success "; echo" page-1 ). "'> Previous page"; echo "page + 1 ). "'> next page"; echo "page_num. "'> last page"; echo "total ". $ this-> page_num. "page marker"; echo "current number ". $ this-> page. "page ";}}
I will give you some of the search pages.
Below is the PHP search page
Include ("c. php"); // c. php is the above PHP program
$ Keyword = $ _ POST ['search'];
$ SQL = mysql_query ("select * from didian where name like '% $ keyword % '");
$ Row = @ mysql_fetch_object ($ SQL );
If (! $ Row ){
Echo "the information you searched for does not exist. please search with similar keywords! ";
}
If ($ keyword = 'Beijing '){
$ Pages = new Page ('select * FROM 'image _ beijing '', 3 );
}
Code .. If it is displayed in a class, it can be displayed on the next page, but the page cannot be displayed on the search page. you can only view the home page, but there is no information on the page, what is the problem... Tutorial ~~~ Thanks...
Reply to discussion (solution)
When turning pages, check whether the $ this-> page has changed.
The search suffix hasn't changed ...... If it is executed in the class, it will change ...... Are you sure you want ......
When turning pages, check whether the $ this-> page has changed.
No suffix changed for the search page ~ There is no suffix ...... Class is changed ...... Do you have any solutions? Or 2
I asked if the page changes.
I asked if the page changes.
This ...... I did not pay attention to it ~ Try again in the dormitory after class ...... However, I guess it hasn't changed ~
I asked if the page changes.
Only the homepage ~ That is, the first page ...... Click the next page, and no data is found ~ Display the current first page ...... Not changed ...... How can this problem be solved?
So I suggest you rewrite it and remove the database operation part from the class.
Class Page {private $ page; // The current Page number, private $ page_num; // The total number of data pages. private $ page_size is displayed. // The number of data entries displayed on each page is private $ SQL; // The queried SQL statement private $ total_Num; // total number of records public $ limit; // The limit control statement public function _ construct ($ total = 100, $ page_size = 3) {$ this-> total_Num = $ total; $ this-> page_size = $ page_size; $ this-> page_num = ceil ($ this-> total_Num/$ page_size); // calculate the total number of pages $ temp = (isset ($ _ GET ["page"])? $ _ GET ["page"]: 1); // GET the current page $ this-> setpage ($ temp); $ this-> showpage (); $ this-> showFoot ();} private function showpage () {$ this-> limit = "LIMIT ". ($ this-> page-1) * $ this-> page_size ). ",". $ this-> page_size; // limit Statement} private function setpage ($ page) {if ($ page <1) {$ page = 1 ;} else if ($ page> $ this-> page_num) {$ page = $ this-> page_num;} $ this-> page = $ page;} private function showFoot () {echo"
"; Echo" homepage success "; echo" page-1 ). "'> Previous page"; echo "page + 1 ). "'> next page"; echo "page_num. "'> last page"; echo "total ". $ this-> page_num. "page marker"; echo "current number ". $ this-> page. "page ";}}
So I suggest you rewrite it and remove the database operation part from the class.
Class Page {private $ page; // The current Page number, private $ page_num; // The total number of data pages. private $ page_size is displayed. // The number of data entries displayed on each page is private $ SQL; // The queried SQL statement private $ total_Num; // total number of records public $ limit; // The limit control statement public function _ construct ($ total = 100, $ page_size = 3) {$ this-> total_Num = $ total; $ this-> page_size = $ page_size; $ this-> page_num = ceil ($ this-> total_Num/$ page_size); // calculate the total number of pages $ temp = (isset ($ _ GET ["page"])? $ _ GET ["page"]: 1); // GET the current page $ this-> setpage ($ temp); $ this-> showpage (); $ this-> showFoot ();} private function showpage () {$ this-> limit = "LIMIT ". ($ this-> page-1) * $ this-> page_size ). ",". $ this-> page_size; // limit Statement} private function setpage ($ page) {if ($ page <1) {$ page = 1 ;} else if ($ page> $ this-> page_num) {$ page = $ this-> page_num;} $ this-> page = $ page;} private function showFoot () {echo"
"; Echo" homepage success "; echo" page-1 ). "'> Previous page"; echo "page + 1 ). "'> next page"; echo "page_num. "'> last page"; echo "total ". $ this-> page_num. "page marker"; echo "current number ". $ this-> page. "page ";}}
Why $ total = 100? I have no 100 pages ..
I asked if the page changes.
If you write it in time, I still have no data on the next page. I output images.
The search1.php is displayed on the next page? Page = 2
The homepage does not have a suffix for search1.php...
I asked if the page changes.
If you write it like this, I don't know the output statement $ pages = new Page (); which is followed by the parameter ..
$ Pages = new Page (total number of pages );
$ Pages = new Page (total number of pages );
Jump to the second page or blank... Is there an error?
The code is as follows:
If ($ keyword = 'guilin '| $ keyword = 'Guangxi Guilin') {$ result = mysql_query ("select * from image_guilin limit 3 "); while ($ abc = @ mysql_fetch_array ($ result) {echo ""; echo"
";}$ Pages = new Page (8, 3 );}
See what $ keyword is.
See what $ keyword is.
$ Keyword = $ _ POST ['search']; $ SQL = mysql_query ("select * from didian where name like '% $ keyword % '"); $ row = @ mysql_fetch_object ($ SQL); if (! $ Row) {echo "the information you searched for does not exist. please search with similar keywords! ";}
Is a user-input search box
See what $ keyword is.
The problem has been solved. it turns out that there is a problem with my parameters .. Thank you.