Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP]Wyświetlanie ostatniej strony przy paginacji
eurosoft
post
Post #1





Grupa: Zarejestrowani
Postów: 179
Pomógł: 0
Dołączył: 5.11.2010

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


Witam Wszytskich!
Mam w serwisie zastosowana paginację na stronie, czy istnieje mozliwość aby podczas otwierania strony została automatycznie załadowana ostatnia strona?
Temat dla mniejest nie do przejścia, a już goooooglowałem i szukałem wszędzie.

dziękuję za wszelkie podpowiedzi.

P.s. Wszytskiego dobrego w Nowym Roku!
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
eurosoft
post
Post #2





Grupa: Zarejestrowani
Postów: 179
Pomógł: 0
Dołączył: 5.11.2010

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


  1. $ileNaStronie=27;
  2. $tabela = 'book';
  3. $tabela1 = 'shot';
  4.  
  5.  
  6. if(!isset($_GET[page]))
  7. {
  8. $strona=1;
  9. }
  10. else
  11. $strona=$_GET[page];
  12. $from=($strona-1)*$ileNaStronie;
  13.  
  14. $sql = "SELECT COUNT(*) FROM $tabela WHERE nr_obw='{$_SESSION['nr_obw']}'";
  15. $result = mysql_query($sql) or die('Queryproblem: ' . mysql_error());
  16. $ilePozycji = mysql_result($result, 0);
  17.  
  18. $sql = "SELECT * FROM $tabela WHERE nr_obw='{$_SESSION['nr_obw']}' LIMIT $from, $ileNaStronie";
  19. $result = mysql_query($sql) or die('Queryproblem: '.mysql_error());
  20. $zlicz = mysql_num_rows($result);
  21.  
  22. $sql1 = "SELECT
  23. book.id_book,
  24. book.imie_nazwisko,
  25. book.start_pol,
  26. shot.animals,
  27. shot.animals1,
  28. shot.animals2,
  29. shot.ilosc,
  30. shot.ilosc1,
  31. shot.ilosc2,
  32. shot.ilosc_shot,
  33. shot.login
  34. FROM book LEFT JOIN shot ON book.id_book=shot.id_book where book.nr_obw='{$_SESSION['nr_obw']}' LIMIT $from, $ileNaStronie";
  35. $result1 = mysql_query($sql1) or die('Queryproblem: '.mysql_error());
  36. if($zlicz)
  37. {
  38.  
  39. if($ilePozycji>$ileNaStronie)
  40. {
  41. $ileStron=ceil($ilePozycji/$ileNaStronie);
  42.  
  43. if($strona>1) //poprzednia strona
  44. {
  45. echo"<a href=\"?=&page=";
  46. echo $strona-1;
  47. echo "&$order\">Poprzednia</a>";
  48. echo "&nbsp;&nbsp;";
  49.  
  50. echo"<a href=\"?=&page=";
  51. echo 1;
  52. echo "&$order\">1</a>";
  53. echo "&nbsp;&nbsp;";
  54. }
  55. //////////////////////////////////////////////
  56. function odnosnik($page, $ofs)
  57. {
  58. global $order;
  59. if($page-$ofs > 1)
  60. {
  61. echo"<a href=\"?=&page=";
  62. echo $page-$ofs;
  63. echo "&$order\">";
  64. echo $page-$ofs;
  65. echo "</a>";
  66. echo "&nbsp;&nbsp;";
  67. }
  68. }
  69. function odnosnikr($page, $ofs, $pagenum)
  70. {
  71. global $order;
  72. if($page+$ofs < $pagenum)
  73. {
  74. echo"<a href=\"?=&page=";
  75. echo $page+$ofs;
  76. echo "&$order\">";
  77. echo $page+$ofs;
  78. echo "</a>";
  79. echo "&nbsp;&nbsp;";
  80. }
  81. }
  82.  
  83. odnosnik($strona,20);
  84. odnosnik($strona,10);
  85. odnosnik($strona,2);
  86. odnosnik($strona,1);
  87. echo $strona;
  88. echo "&nbsp;&nbsp;";
  89. odnosnikr($strona,1,$ileStron);
  90. odnosnikr($strona,2,$ileStron);
  91. odnosnikr($strona,10,$ileStron);
  92. odnosnikr($strona,20,$ileStron);
  93.  
  94. if($strona<$ileStron)
  95. {
  96. echo"<a href=\"?=&page=";
  97. echo $ileStron;
  98. echo "&$order\">$ileStron</a>";
  99.  
  100. echo "&nbsp;&nbsp;";
  101.  
  102. echo"<a href=\"?=&page=";
  103. echo $strona+1;
  104. echo "&$order\">Następna</a>";
  105.  
  106. }
  107. }
  108. }
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 16.10.2025 - 00:38