Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [MySQL][PHP] Stronicowanie wyników wyszukiwania
Kshyhoo
post 6.02.2010, 20:50:15
Post #1





Grupa: Opiekunowie
Postów: 3 855
Pomógł: 317
Dołączył: 4.01.2005
Skąd: że




Męczę się ze stronicowaniem wyszukiwania. Niby linki do kolejnych stron są ok, a wciąż mam pierwszą stronę. Oto kodzik:

  1. function makepagenav($start, $count, $total, $range = 0, $link = "") {
  2.  
  3. if ($link == "") { $link = "cpax.php?go=search"; }
  4.  
  5. $pg_cnt = ceil($total / $count);
  6. if ($pg_cnt <= 1) { return ""; }
  7.  
  8. $idx_back = $start - $count;
  9. $idx_next = $start + $count;
  10. $cur_page = ceil(($start + 1) / $count);
  11.  
  12. $res = "Strona ".$cur_page." z ".$pg_cnt.": ";
  13. if($idx_back >= 0) {
  14. if($cur_page > ($range + 1)) {
  15. $res .= " <a href='cpax.php?go=search&".$link."rowstart=0'>1</a> ... ";
  16. }
  17. }
  18. $idx_fst = max($cur_page - $range, 1);
  19. $idx_lst = min($cur_page + $range, $pg_cnt);
  20. if ($range == 0) {
  21. $idx_fst = 1;
  22. $idx_lst = $pg_cnt;
  23. }
  24. for ($i = $idx_fst; $i <= $idx_lst; $i++) {
  25. $offset_page = ($i - 1) * $count;
  26. if ($i == $cur_page) {
  27. $res .= "<span><strong>".$i."</strong></span>";
  28. } else {
  29. $res .= " <a href='cpax.php?go=search&".$link."rowstart=".$offset_page."'>".$i."</a> ";
  30. }
  31. }
  32. if ($idx_next < $total) {
  33. if ($cur_page < ($pg_cnt - $range)) {
  34. $res .= " ...<a href='cpax.php?go=search&".$link."rowstart=".($pg_cnt - 1) * $count."'>".$pg_cnt."</a>\n";
  35. }
  36. }
  37.  
  38. return "<div class='pagenav'>\n".$res .$link."</div>\n";
  39. }
  40.  
  41. ...
  42.  
  43. $navigation_result = "<div align='center' style='margin-top:5px;'>\n".makePageNav($_GET['rowstart'], 10, ($site_search_count > 100 || search_globalarray("") ? 100 : $site_search_count), 3, "fraza=".urlencode($_GET['fraza'])."&amp;".$composevars)."\n</div>\n";

Linki do stron:
Cytat


EDIT: Znalazłem problem. W linku pokazuje się search=Szukaj za co winny jest kod:
  1. echo "<input type='submit' name='search' value='Szukaj' class='button' />\n</td>\n";



Ten post edytował Kshyhoo 6.02.2010, 20:59:10


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 06:36