Why does my PHP page not turn to the next page?

Source: Internet
Author: User
I have defined a class to output the following is the Class property ... And finally the search page.
Include ("script/conn.php");        Class page{private $page;//Current page number private $page _num;//data Total How many pages show private $page _size;//the number of data bars displayed per page private $sql;//Query SQL statement private $limit;//The Limit control statement after the query statement private $total _num;//total number of records public function __constr            UCT ($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 total pages $this->sql = $sql;            $temp = (isset ($_get["page"])? $_get["Page"]: 1);//Gets 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->sq            L. $this->limit);       if (! $result) {//determine if the result exists         if ($this->page_num > 0) {//If not present and the number of pages 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 "Home 丨"; echo "page-1)." > previous page 丨 "; echo "page + 1)." > Next 丨 "; echo "Page_num." > End 丨 "; echo" Total ". $this->page_num." Page 丨 ", echo" current section ". $this->page." Page "; } }

I'll give you a part of the search page.

Here is the PHP search page
Include ("c.php");//c.php is the PHP program above
$keyword =$_post[' search ';
$sql =mysql_query ("SELECT * from Didian the where name like '% $keyword% '");
$row = @mysql_fetch_object ($sql);
if (! $row) {
echo "the information you searched for does not exist, please use a similar keyword to retrieve it!";
}
if ($keyword = = ' Beijing ') {
$pages = new Page (' SELECT * from ' image_beijing ', 3);
}
The code is like this: As shown in the class can be implemented to turn to the next page, but to the search page cannot page, can only see the homepage, a page on what information is not, I want to ask what is the problem ah ... Ask for advice ~ ~ ~ Thank ...


Reply to discussion (solution)

See if $this->page change when you turn the page

Search page suffix has not changed ... If the execution in the class is changed ... Do you have any idea ...

See if $this->page change when you turn the page

Search page does not change suffix ~ there is no suffix ... The class inside is changed ... Do you have any way to solve it? Or are you going to put 2.

I'm asking if there's a change in $this->page.

I'm asking if there's a change in $this->page.

This one...... did not notice ~ class back to the dormitory to try ... But I don't think it's changed.

I'm asking if there's a change in $this->page.

can only see the homepage ~ that is the first page ... Click Next page on the data no ~ show the current first page ... No change ... How to solve?

Then I suggest you rewrite the database Operations section from the class.

Class page{private $page;    Current page number private $page _num;    The total number of pages of data shows private $page _size;    Number of data bars displayed per page private $sql;    SQL statement for query private $total _num;    Total number of records public $limit;    The limit control statement after the query 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 Total Pages $temp = (isset ($_get["page"])? $_get["Page"]: 1);    Gets 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 "Home 丨"; echo "page-1)." > previous page 丨 "; echo "page + 1)." > Next 丨 "; echo "Page_num." > End 丨 "; echo "Shared". $this->page_num. " Page 丨 "; echo "Current section". $this->page. " Page "; }}

Then I suggest you rewrite the database Operations section from the class.

Class page{private $page;    Current page number private $page _num;    The total number of pages of data shows private $page _size;    Number of data bars displayed per page private $sql;    SQL statement for query private $total _num;    Total number of records public $limit;    The limit control statement after the query 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 Total Pages $temp = (isset ($_get["page"])? $_get["Page"]: 1);    Gets 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 "Home 丨"; echo "page-1)." > previous page 丨 "; echo "page + 1)." > Next 丨 "; echo "Page_num." > End 丨 "; echo "Shared". $this->page_num. " Page 丨 "; echo "Current section". $this->page. " Page "; }}


Why $total=100? I don't have 100 pages.

I'm asking if there's a change in $this->page.


In time according to your method of writing, I click on the next page is still no data, I output is a picture
The next page shows this search1.php?page=2
Home is this search1.php no suffix ...

I'm asking if there's a change in $this->page.


If you write like this, I don't know. The output statement $pages = new Page (), followed by what parameters good:

$pages = new Page (total, per page);

$pages = new Page (total, per page);

Jump to the second page or blank ... Is there something wrong with me?
The display 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);}

Let's see what $keyword is.

Let's 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 use a similar keyword to retrieve it! ";}
is a user-entered search box

Let's see what $keyword is.

has been solved, it turns out that I have a problem with the parameter. Thank you, sir.
  • 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.