Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP]MAX stronnicowania
Maniek1313
post 1.09.2011, 17:50:50
Post #1





Grupa: Zarejestrowani
Postów: 148
Pomógł: 2
Dołączył: 8.07.2011

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


Witam znalazłem na stronie kod stronnicowania i go trochę przerobiłem i mam jeden problem a mianowicie chciałbym żeby jak dojdzie po klikaniu na następny na ostatnią stronę z wynikami to żeby zniknął przycisk następna.

Oto kod :

  1. <?php
  2. require 'header.php';
  3. include("connect.php");
  4. $bazadanych;
  5. or die("Nie ma takiej bazy danych");
  6. $res2 = mysql_query("SELECT * FROM filmiki") or die("Blad tabeli");
  7.  
  8. $perPage = 3;
  9. if (is_numeric($_REQUEST['page'])) {
  10. $page = (int) $_REQUEST['page'];
  11. if ($page < 1) {
  12. $page = 1;
  13. }
  14. } else {
  15. $page = 1;
  16. }
  17. $start = ($page - 1) * $perPage;
  18. //SELECT * FROM art LIMIT 0 , 4 - gdy jestes na stronie glownej
  19. $query = "SELECT * FROM filmiki ORDER BY `filmiki`.`id` DESC LIMIT ".$start." , ".$perPage;
  20.  
  21. $result = mysql_query($query);
  22.  
  23. while($rekord = mysql_fetch_array($result))
  24. {
  25.  
  26. echo '<div class="art-post-inner art-article">
  27. <div class="art-postmetadataheader">
  28. <h2 class="art-postheader">
  29. <center>'.$rekord["nazwa"].'</center>
  30. </h2>
  31. </div>
  32. <div class="art-postcontent">
  33. <p><center><iframe width="560" height="345" src="http://www.youtube.com/embed/'.$rekord["link"].'" frameborder="0" allowfullscreen></iframe></center></p>
  34.  
  35.  
  36. </div>
  37. <div class="cleared"></div>
  38. </div>';
  39. }
  40. $prev = $page - 1;
  41. $next = $page + 1;
  42. $prevLink = $_SERVER['PHP_SELF'] . '?page=' . $prev;
  43. $nextLink = $_SERVER['PHP_SELF'] . '?page=' . $next;
  44.  
  45. $page = (int) $_REQUEST['page'];
  46. if (is_numeric($_REQUEST['page'])) {
  47.  
  48. if ($page != 1) {
  49. echo "<center><a href=".$prevLink.">Poprzednia</a></center>";
  50.  
  51. }
  52. }
  53.  
  54. echo "<br />";
  55. echo "<center><a href=".$nextLink.">Nastepna</a></center>";
  56. mysql_close($bazadanych)
  57. or die("Nie mogę rozłączyć się z bazą danych");
  58. require 'footer.php';
  59. ?>
Go to the top of the page
+Quote Post

Posty w temacie


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 - 18:43