Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem ze Stronicowaniem
-Gość_Hardknox_*-
post
Post #1





Goście







Mam problem przy modyfikowaniu cmsa, podstrony mi wychodzą, ale po kliknieciu nie przechodzi do wyswietlania kolejnych 3 z bazy

  1. <?php
  2. function wyswietl_newsy() {
  3.  
  4. connect();
  5. $ile = 3;
  6. $numrows = mysql_num_rows(mysql_query("SELECT id, tytul, autor, data, tresc FROM news")); 
  7.  
  8.  
  9.  
  10. if(!$p) $p = 0; 
  11.  
  12. $p = (int)$p; 
  13. $ile = (int)$ile; 
  14. $query = mysql_query("SELECT id, tytul, autor, data, tresc FROM news ORDER BY id DESC LIMIT $p,$i
    le"
    );
  15.  
  16.  
  17.  
  18.  while ($news = mysql_fetch_array($query))
  19. {
  20. include("show_news.php");
  21. }
  22.  
  23.  
  24. echo '<center>Strony: [';
  25.  
  26. for($i=0;$i<ceil($numrows/$ile);$i++) { 
  27. echo ' <a href="'.$PHP_SELF.'?p'.($i*$ile).'">'.($i+1).'</a> ';
  28. }
  29.  
  30. echo '] </center>';
  31. ?>
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
TomASS
post
Post #2





Grupa: Zarejestrowani
Postów: 1 660
Pomógł: 13
Dołączył: 9.06.2004
Skąd: Wrocław i okolice

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


@Cysiaczek:
A jak napiszesz:

  1. SELECT * FROM tabela LIMIT 10, 3;



Nie wiedziałem że LIMIT n m wyświetla rekordy od n do m (z Twojego tłumaczenia tak to można wywnioskować), raczej myślałem, że:

Cytat
The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must both be non-negative integer constants (except when using prepared statements).

With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1):

SELECT * FROM tbl LIMIT 5,10; # Retrieve rows 6-15
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: 8.10.2025 - 09:59