06-08-2010, 21:42
Może ktoś podpowiedzieć co należy przekazać do zmiennej from bo trzy pozostałe to każdy wie 

Kod:
1. function pagination($found, $link, $from, $limit) {
2. $number = ceil($found / $limit);
3. if ($number < 2)
4. return '<strong>1</strong>';
5. $str = '';
6. if ($number > 9) {
7. $max = ($from > 5) ? 3 : $from + 3;
8. for ($num = 1; $num < $max; $num++) {
9. if ($num == $from)
10. $str .= '<strong>'.$num.'</strong> ';
11. else
12. $str .= '<a href="'.$link.$num.'">'.$num.'</a> ';
13. }
14. if ($from > 5 && $from <= $number) {
15. $str .= '... ';
16. $max = ($from < $number - 3) ? $from + 3 : $number - 1;
17. for ($num = $from - 2; $num < $max; $num++) {
18. if ($num == $from)
19. $str .= '<strong>'.$num.'</strong> ';
20. else
21. $str .= '<a href="'.$link.$num.'">'.$num.'</a> ';
22. }
23. if ($from < $number - 4)
24. $str .= '... ';
25. } else
26. $str .= '... ';
27. for ($num = $number - 1; $num <= $number; $num++) {
28. if ($num == $from)
29. $str .= '<strong>'.$num.'</strong> ';
30. else
31. $str .= '<a href="'.$link.$num.'">'.$num.'</a> ';
32. }
33. } else {
34. for ($num = 1; $num <= $number; $num++) {
35. if ($num == $from)
36. $str .= '<strong>'.$num.'</strong> ';
37. else
38. $str .= '<a href="'.$link.$num.'">'.$num.'</a> ';
39. }
40. }
41. return $str;
42. }