944,030 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1467
  • PHP RSS
Oct 30th, 2006
0

pagination problem

Expand Post »
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:
PHP Syntax (Toggle Plain Text)
  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. ?>
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
alice1 is offline Offline
1 posts
since Oct 2006
Oct 30th, 2006
0

Re: pagination problem

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
Reputation Points: 10
Solved Threads: 2
Junior Poster
sn4rf3r is offline Offline
133 posts
since Sep 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Storing dynamic form values in Arrays for display & insert
Next Thread in PHP Forum Timeline: PHP converter





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC