Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Problem ze Stronicowaniem
-Gość_Hardknox_*-
post 6.07.2006, 13:10:27
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
Cysiaczek
post 6.07.2006, 17:17:07
Post #2





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




1. Co to za CMS (ewentualnie kto to cos tak nazwał winksmiley.jpg )
2. Napiszę to ... naprawdę to zrobię... mówie poważnie...uwaga...
register_globals=off
3. Istneje tez taka możliwiść, że źle zrozumiałeś LIMIT w zapytaniu sql. Te dwie wartości, to rekord startowy i rekord końcowy.


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
TomASS
post 6.07.2006, 22:35:22
Post #3





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
Cysiaczek
post 7.07.2006, 06:55:44
Post #4





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




Cóż. Zdarza się, że napiszę jakąś głupotę - mój powyższy post taką właśnie zawiera, za co przepraszam wszystkich, którzy mogli się nim kierować.
Nie wiem, czym się sugerowałem pisząc coś takiego, ale nic mnie nie tłumaczy sadsmiley02.gif


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
TomASS
post 7.07.2006, 09:04:15
Post #5





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

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


@Cysiaczek :

Każdemu się zdaża - rada na przyszłość, zanim coś napiszesz, to sprawdź, poprzyj swoją wypowiedź linkiem/cytatem.... tongue.gif


@Gość :
gdzie masz zdefiniowane $p ?

  1. <?php
  2. if(!$p) $p = 0; 
  3. $p = (int)$p;
  4. ?>

W tym wypadku $p zawsze będzie miał wartość 0.


--------------------
Go to the top of the page
+Quote Post
Cysiaczek
post 7.07.2006, 09:05:26
Post #6





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




Właśnie dlatego piszę o register_globals - przenosi w linku smile.gif


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
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: 15.06.2025 - 09:08