pagination problem

Reply

Join Date: Oct 2006
Posts: 1
Reputation: alice1 is an unknown quantity at this point 
Solved Threads: 0
alice1 alice1 is offline Offline
Newbie Poster

pagination problem

 
0
  #1
Oct 30th, 2006
I have a problem of pagination of turns out you of one query of search on a DB MySQL. With this code I succeed to visualize the first 5 records out to you in one page but when go in the successive pages it makes to see the first 5 records me of mine database. This is the code:
  1. <?php
  2. $db_host="....";
  3. $db_user="....";
  4. $db_password="...";
  5. $db_database="...";
  6. $c or die ("Errore nella connessione al Mysql:" . mysql_error());
  7. mysql_select_db($db_database,$connessione) or die ("Errore nella selezione del db:" . mysql_error());
  8.  
  9. $numero_record = 5;
  10. if(!isset($HTTP_GET_VARS["inizio"])){
  11. $inizio = 0;
  12. }else{
  13. $inizio = $HTTP_GET_VARS["inizio"];
  14. }
  15. $query_limit="SELECT AnnoRipresa, Id, FROM table_name WHERE AnnoRipresa LIKE '%$_POST[AnnoRipresa]%'
  16. order by Id limit $inizio, $numero_record" or die ("Errore :" . mysql_error());;
  17.  
  18. $query = mysql_query($query_limit);
  19.  
  20. $select = "SELECT AnnoRipresa, Id, FROM table_name WHERE AnnoRipresa LIKE '%$_POST[AnnoRipresa]%'";
  21.  
  22. $query2 = mysql_query($select);
  23.  
  24. $numero_record_totali = mysql_numrows($query2);
  25.  
  26. $numero_pagine = ceil($numero_record_totali/$numero_record);
  27.  
  28. $pagina_corrente = ceil(($inizio/$numero_record) + 1);
  29. while($riga=mysql_fetch_array($query))
  30. {?>
  31. <tr>
  32. <td colspan="2">
  33. <?php
  34. echo <tr>
  35. <td height="22" width="20%"><h4><b>Anno Ripresa</b></td>
  36. echo "<td>" . $riga['Id'] . "</td>";
  37. echo "</tr>";
  38. }
  39. if($numero_pagine > 1){
  40. for($pagina = 1; $pagina <= $numero_pagine; $pagina++){
  41. if($pagina == $pagina_corrente){ ?>
  42. <b><?=$pagina?></b>
  43. <?php }else{
  44. ?>
  45. <a href="fotografie_aeree_verticali.php?inizio=<?=(($pagina - 1) * $numero_record)?>"><?=$pagina?></a>
  46. <?php
  47. }
  48. }
  49. }
  50. ?>
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 133
Reputation: sn4rf3r is an unknown quantity at this point 
Solved Threads: 2
sn4rf3r's Avatar
sn4rf3r sn4rf3r is offline Offline
Junior Poster

Re: pagination problem

 
0
  #2
Oct 30th, 2006
have you tried the PEARager package? It is really easy to use and is debugged for you. There are also plenty of other packages around, try phpclasses.org as well.
Last edited by sn4rf3r; Oct 30th, 2006 at 12:26 pm. Reason: fixed link
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC