Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [HTML][MySQL][PHP]błąd w paginacji
Silny
post 2.10.2010, 19:12:34
Post #1





Grupa: Zarejestrowani
Postów: 117
Pomógł: 2
Dołączył: 29.06.2010

Ostrzeżenie: (0%)
-----


Witam, mam problem z paginacją....
gdzie tu błąd??
  1. <?php
  2. include("includes/header.php");
  3. include("includes/headline.php");
  4. include("common.php");
  5.  
  6. $szablon->set_filenames(array(
  7. 'body' => 'articles_body.tpl')
  8. );
  9.  
  10. $lang = $lang['all_articles'];
  11. $liczRekordy = mysql_num_rows(mysql_query("SELECT id FROM articles"));
  12. if ($liczRekordy > 0) {
  13. echo '<center><font size="5"> '.$lang.' '.$liczRekordy.' </font></center>';
  14. } else {
  15. echo '<center><font size="5">Nie mamy artykułów w bazie.</font></center>';
  16. }
  17.  
  18. $subpage = $_GET['page'];
  19. $perPage = 5;
  20. if (!empty($_GET['subpage']) AND (is_numeric($_GET['subpage'])))
  21. {
  22. $subpage = (int) $_GET['subpage'];
  23. }
  24. if ($subpage < 1)
  25. {
  26. $subpage = 1;
  27. }
  28. $start = ($subpage - 1) * $perPage;
  29. $zapytanie = 'SELECT id, tytul, autor, data FROM articles ORDER BY `id` DESC LIMIT '.$start.', '.$perPage.'';
  30. $idzapytania = mysql_query($zapytanie);
  31. if(mysql_real_escape_string((!isset($_GET['id'])) or empty($_GET['id'])))
  32. {
  33. $szablon->assign_vars(array(
  34. 'ID' => $row['id'],
  35. 'AUTOR' => $row['autor'],
  36. 'TYTUL' => $row['tytul'],
  37. 'DATA' => $row['data'],
  38. ));
  39. $prev = $subpage - 1;
  40. $next = $subpage + 1;
  41. $prevLink = 'articles.php?page='.$prev;
  42. $nextLink = 'articles.php?page='.$next;
  43. $ilosc_wierszy = mysql_num_rows($idzapytania);
  44. if($subpage > 1)
  45. echo'<a style="text-decoration: none;" href="'.$prevLink.'">Poprzednia strona</a> ';
  46. $stron=round($ilosc_wierszy/$perPage);
  47. for($i=1; $i<=$stron; ++$i)
  48. {
  49. if($subpage > 1)
  50. echo $i;
  51. else
  52. echo '<a style="text-decoration: none;" href="articles.php?page='.$i.'">'.$i.' </a>';
  53. }
  54. echo ' <a style="text-decoration: none;" href="'.$nextLink.'">Następna strona</a>';
  55. }
  56. $szablon->pparse('body');
  57. include('includes/footer.php');
  58. ?>
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
Ruio
post 2.10.2010, 19:41:34
Post #2





Grupa: Zarejestrowani
Postów: 147
Pomógł: 9
Dołączył: 20.02.2009

Ostrzeżenie: (0%)
-----


Wyrzuca ci jakiś błąd questionmark.gif opisz problem bardziej... co dokładnie nie działa ?

Go to the top of the page
+Quote Post
Silny
post 2.10.2010, 19:44:47
Post #3





Grupa: Zarejestrowani
Postów: 117
Pomógł: 2
Dołączył: 29.06.2010

Ostrzeżenie: (0%)
-----


Kod
1  Następna strona
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/public_html/nice/cache/tpl2_style.articles_body. on line 2
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: 19.07.2025 - 06:55