468,740 Members | 1,991 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,740 developers. It's quick & easy.

Search engine pagination shows a blank page on every page except page 1

62
Hi,
In my site i set a serach engine page.Which customer could put key word and find the user name in database,
I set in one page will show 40 people. If over 40 the page will set to be other next page..
Well, everything work fine at the 1st page, But when i click on the 2nd page or next page to see the result ...those next page is empty.Seem like the page knows how many record in that keyword but can not show the record in next page...then evrything is empty on next page...
I got stress too much, I never have problem about this if i specify only one name one result....
But this i use trimm to explode the key word i dont know where to fix it

Alex
Aug 31 '07 #1
3 1975
gregerly
192 Expert 100+
Hi,
In my site i set a serach engine page.Which customer could put key word and find the user name in database,
I set in one page will show 40 people. If over 40 the page will set to be other next page..
Well, everything work fine at the 1st page, But when i click on the 2nd page or next page to see the result ...those next page is empty.Seem like the page knows how many record in that keyword but can not show the record in next page...then evrything is empty on next page...
I got stress too much, I never have problem about this if i specify only one name one result....
But this i use trimm to explode the key word i dont know where to fix it

Alex
I have a feeling that your not properly using SQL's LIMIT. Without seeing any of your code it's hard to tell, please post some code and we can probably help you further.

Greg
Aug 31 '07 #2
pbmods
5,821 Expert 4TB
Heya, Paitoon.

Changed thread title to better describe the problem (did you know that threads whose titles do not follow the Posting Guidelines actually get FEWER responses?).

If you're getting a blank page, your script is probably generating an error. Check out this article to find out what is going on.
Aug 31 '07 #3
paitoon
62
ok the main script is here;
Expand|Select|Wrap|Line Numbers
  1. <?  //////////THis is the script that i put above the head doccument/////////
  2. $page=$_GET[page];
  3. if ($page=="") {
  4.         $page=1;
  5. }
  6. $each=20; // specify number of image per one page//
  7. ?>
  8.  
Expand|Select|Wrap|Line Numbers
  1. <?  ////////This part is in body
  2. $sql="select * from users where";
  3.     $check=0;
  4.  
  5.     if  ($sex<>"*") {
  6.  
  7.         $sql.=" sex='$sex' ";
  8.         $check=1;
  9.     }
  10.  
  11.     if ($lookfor<>"*") {
  12.         if ($check==1) {
  13.             $sql.=" AND lookfor='$lookfor' ";
  14.         } else {
  15.             $sql.=" lookfor='$lookfor' ";
  16.         }
  17.         $check=1;
  18.     }
  19.  
  20.  
  21.  
  22.  
  23.     $sql2="select * from users where sex='$sex'  or lookfor='$lookfor' province'";
  24.     $result2=mysql_db_query($dbname,$sql2);
  25.     $total=mysql_num_rows($result2);
  26.                 $totalpages=ceil($total/$each);
  27.     $goto = ($page-1)*$each;
  28.  
  29.  
  30.     $sql.=" order by username  limit $goto,$each";
  31.     $result=mysql_db_query($dbname,$sql);
  32.     while ($rs=mysql_fetch_array($result)) {
  33.         $username=$rs[username];
  34.         $password=$rs[password];
  35.         $userid=$rs[userid];
  36.  
  37.     ?>
  38.  
  39.  
  40.  
  41.  <?  ///////////////// And this is the last
  42.  
  43.     if ($totalpages>1) { 
  44.         echo "<B>หน้า $page</B><BR>";
  45.         for ($i=1;$i<=$totalpages;$i++) {
  46.                 echo "| <A HREF='search2.php?page=$i'>$i</A> ";
  47.         }
  48.     }
  49. ?>

everything work correctly,I set it to show 10 results each page..But when i click on the link to page number 2 it show wrong....i got all every information in database even i am not searching for it...But why the first page is work correctly...what should i do ?
Thank you so much for the further help

Alex
Sep 4 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

11 posts views Thread by Petre Huile | last post: by
reply views Thread by Mark Goldin | last post: by
11 posts views Thread by ste | last post: by
4 posts views Thread by MDW | last post: by
4 posts views Thread by comp.lang.php | last post: by
1 post views Thread by shalini jain | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
xarzu
2 posts views Thread by xarzu | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.