Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Stronnicowanie wyniku zapytania...
imm
post
Post #1





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 11.04.2003

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


Mam skrypt, ktory pobiera z bazy ilosc rekordow, dzieli na strony i wyswietla np tak: 1 2 3 4 5 6 7 8 9...20. Wszystko super. Moj problem polega na tym ze nie potrafie napisac skryptu, ktory by wyswietlal te numerki w taki sposob:
Klikam na 6 i chce zeby po przeladowaniu skrypt generowal: 3 4 5 6 7 8 9 10 11 12 ... 20, a teraz klikne na 12 i po przeladowaniu 9 10 11 12 13 14 15 16 17 ... 20, albo klikam na 10 i mam 7 8 9 10 11 12 13 14 15 ... 20.
Chyba to w miare jasno wyjasnilem (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif) . Google w ten sposob segreguje wyniki wyszukiwania.
Pozdrawiam i prosze o pomoc bo juz nie moge... (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
awides
post
Post #2





Grupa: Zarejestrowani
Postów: 40
Pomógł: 0
Dołączył: 4.11.2004

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


ostatnio napisałem coś takiego
  1. <?php
  2.  
  3. function naglowek_forum($id, $strona) 
  4.  {
  5.  $wynik = @mysql_query(&#092;"SELECT count(xxx) 
  6. FROM xxx
  7. WHERE xxx = '$id'&#092;");
  8.  
  9.  $ilosc_postow = mysql_result($wynik, 0, 'count(xxx)'); 
  10.  
  11.  $a = $ilosc_postow / 15;
  12.  
  13.  if (gettype($a) == 'integer') {
  14.  for($i=1; $i<=$a; $i++) {
  15.  $I = $i;
  16.  }
  17.  }
  18.  else {
  19.  for($i=1; $i<=$a+1; $i++) {
  20.  $I = $i;
  21.  }
  22.  }
  23.  
  24.  if (@ $I > 1 && @ $I < 5) {
  25. echo '<tr><td colspan=\"5\" align=\"right\">Strona: <b>'.(empty($_GET['st']) ? 1 : $_GET['st']).'</b> &nbsp;&nbsp;';
  26.  
  27. if(gettype($a) == 'integer') {
  28.  for($i=1; $i<=$a; $i++) {
  29.  $I = $i;
  30.  echo '<a href=\"index_temat.php?id='.$id.'&st='.$i.'\">[ '.$i.' ]</a>&nbsp;';
  31.  }
  32. }
  33. else {
  34.  for($i=1; $i<=$a+1; $i++) {
  35.  $I = $i;
  36.  echo '<a href=\"index_temat.php?id='.$id.'&st='.$i.'\">[ '.$i.' ]</a>&nbsp;';
  37.  }
  38. }
  39. echo '</td></tr>';
  40.  }
  41.  else if(@ $I > 4) {
  42.  #jeżeli jest wiecej niż 4 strony...
  43.  
  44. echo '<tr><td colspan=\"5\" align=\"right\">Strona: <b>'.(empty($_GET['st']) ? 1 : $_GET['st']).'</b> &nbsp;&nbsp;';
  45. $end = $I;
  46. (empty($_GET['st']) ? $start = 1 : $start = $_GET['st']);
  47.  
  48.  if($start+>= $end) {  
  49. for($i = $end-3; $i <= $end-1; $i++) {
  50. $I = $i;
  51. echo '<a href=\"index_temat.php?id='.$id.'&st='.$i.'\">[ '.$i.' ]</a>&nbsp;';
  52. }
  53. echo '... <a href=\"index_temat.php?id='.$id.'&st='.$end.'\">[ '.$end.' ]</a>&nbsp;';
  54.  }
  55.  else if($start > 1) {
  56. for($i = $start-1; $i < $start+2; $i++) {
  57. $I = $i;
  58. echo '<a href=\"index_temat.php?id='.$id.'&st='.$i.'\">[ '.$i.' ]</a>&nbsp;';
  59. }
  60. echo '... <a href=\"index_temat.php?id='.$id.'&st='.$end.'\">[ '.$end.' ]</a>&nbsp;';
  61.  } 
  62.  else {
  63. for($i = 1; $i < 4; $i++) {
  64. $I = $i;
  65. echo '<a href=\"index_temat.php?id='.$id.'&st='.$i.'\">[ '.$i.' ]</a>&nbsp;';
  66. }
  67. echo '... <a href=\"index_temat.php?id='.$id.'&st='.$end.'\">[ '.$end.' ]</a>&nbsp;';
  68.  }  
  69. echo '</td></tr>';
  70.  }
  71.  }
  72. ?>


mało skomplikowane (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) może to kiedyś dopracuje...

Ten post edytował awides 8.01.2005, 17:53:37
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 Aktualny czas: 12.10.2025 - 11:06