The PHP search results are paginated to show questions.

Source: Internet
Author: User
PHP Search Results page display problem:
Home display no problem, page display data not ... Code
Include_once ("script/conn.php");
Class page{
private $curPage;//Current page
private $totalPages;//How many pages of data are displayed
private $dispNum;//The number of data bars displayed per page
private $queryStr;//SQL statement for query
private $limitStr;//The Limit control statement after the query statement
private $currentPage;//Get current page
Public function __construct ($queryStr = ", $dispNum =3) {
$result = mysql_query ($QUERYSTR);
$totalNum = mysql_num_rows ($result);
$this->dispnum = $dispNum;
$currentPage = basename ($_server["php_self");//Returns the file name part of the path
$this->totalpages = ceil ($totalNum/$dispNum);
$this->querystr = $queryStr;
$temp = (Isset ($_get["Curpage")? $_get["Curpage"]: 1);
$this->setcurpage ($temp);
$this->showcurpage ();
$this->showfoot ();
}
Private Function Showcurpage () {
$this->limitstr = ' LIMIT '. (($this->curpage-1) * $this->dispnum). $this->dispnum;
$result = mysql_query ($this->querystr. $this->limitstr);
while ($row = Mysql_fetch_assoc ($result)) {
echo "";
echo "
";
}
}
Private Function Setcurpage ($curPage) {
if ($curPage < 1) {
$curPage = 1;
}
else if ($curPage > $this->totalpages) {
$curPage = $this->totalpages;
}
$this->curpage = $curPage;
}
Private Function Showfoot () {
Echo ' Home 丨 ';
Echo ' curPage-1). ' " > previous page 丨 ';
Echo ' Curpage + 1). ' " > next page 丨 ';
Echo ' TotalPages. ' " > End 丨 ';
echo "Shared". $this->totalpages. " Page 丨 ";
echo "Current section". $this->curpage. "Page";
}
}
$keyword =$_post[' search ';
$sql =mysql_query ("SELECT * from Didian the where name like '% $keyword% '");
[Email Protected]_fetch_object ($sql);
if (! $raw) {
echo "the information you searched for does not exist, please use a similar keyword to retrieve it!";
}
If this output is not a problem alone: But with this one, the page will not show the data. This is the search box to determine the condition
Switch ($keyword) {
Case ' Guilin ': $pages = new Page (' SELECT * from ' Image_guilin ', 3);
Case ' Hainan ': $pages = new Page (' SELECT * from ' Image_hainan ', 3);
Case ' Beijing ': $pages = new Page (' SELECT * from ' image_beijing ', 3);
Case ' Jiuzhaigou ': $pages = new Page (' SELECT * from ' Image_jiuzhaigou ', 3);
Case ' Taihang Mountain ': $pages = new Page (' SELECT * from ' Image_taihengshan ', 3);
Case ' Shangri-la ': $pages = new Page (' SELECT * from ' Image_xianggelila ', 3);
Case ' Xiao xing ': $pages = new Page (' SELECT * from ' image_xiaoxinganling ', 3);
Case ' Xishuangbanna ': $pages = new Page (' SELECT * from ' Image_xishuangbanna ', 3);
}

followed by an HTML search box jump


I don't know why. Ask for advice ...
------to solve the idea----------------------
$keyword =$_post[' search ';
1. The name you get the parameter is search, not keyword.
2. Because paging is used for GET, it cannot be obtained.

Change it to this.


Include_once ("script/conn.php");
Class page{
private $curPage;//Current page
private $totalPages;//How many pages of data are displayed
private $dispNum;//The number of data bars displayed per page
private $queryStr;//SQL statement for query
private $limitStr;//The Limit control statement after the query statement
private $currentPage;//Get current page
private $keyword;//Keywords
Public function __construct ($queryStr = ", $keyword =", $dispNum =3) {
$result = mysql_query ($QUERYSTR);
$totalNum = mysql_num_rows ($result);
$this->dispnum = $dispNum;
$this->keyword = $keyword;
$currentPage = basename ($_server["php_self"]); Returns the file name portion of the path
$this->totalpages = ceil ($totalNum/$dispNum);
$this->querystr = $queryStr;
$temp = (Isset ($_get["Curpage")? $_get["Curpage"]: 1);
$this->setcurpage ($temp);
$this->showcurpage ();
$this->showfoot ();
}
Private Function Showcurpage () {
$this->limitstr = ' LIMIT '. (($this->curpage-1) * $this->dispnum). $this->dispnum;
$result = mysql_query ($this->querystr. $this->limitstr);
while ($row = Mysql_fetch_assoc ($result)) {
echo "";
echo "
";
}
}
Private Function Setcurpage ($curPage) {
if ($curPage < 1) {
$curPage = 1;
}
else if ($curPage > $this->totalpages) {
$curPage = $this->totalpages;
}
$this->curpage = $curPage;
}
Private Function Showfoot () {
echo ' keyword. ' &curpage=1 "> Home 丨";
echo ' keyword. ' &curpage= '. ($this->curpage-1). ' " > previous page 丨 ';
echo ' keyword. ' &curpage= '. ($this->curpage + 1). ' " > next page 丨 ';
echo ' keyword. ' &curpage= '. $this->totalpages. ' " > End 丨 ';
echo "Shared". $this->totalpages. " Page 丨 ";
echo "Current section". $this->curpage. "Page";
}
}
$keyword =$_request[' search ';
$sql =mysql_query ("SELECT * from Didian the where name like '% $keyword% '");
[Email Protected]_fetch_object ($sql);
if (! $raw) {
echo "the information you searched for does not exist, please use a similar keyword to retrieve it!";
}
?>

  • Related Article

    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.