Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Problem ze skryptem, petla sie petli...
f4ngorn
post
Post #1





Grupa: Zarejestrowani
Postów: 43
Pomógł: 0
Dołączył: 7.08.2005

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


Witam, pisze prosciutki skrypt galerii oparty o pliki (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) Mam drobny problem... z moich wyliczen to powinno smigac ino furczy, niestety tak nie jest :/ Skrypt petli sie do czasu zatrzymania przez serwer, i nie wyswietla nic. Oto kod:
  1. <?php
  2.  
  3. $kat = "sygnaturki";
  4. $file = readdir($handle);
  5.  
  6. if ($handle = opendir($kat))
  7. {
  8. for ($id = 1; $id < $id + 4; $id++){
  9. if ($file != "." && $file != "..")
  10. {
  11. echo "<a href='index.php?strona=strony/przegladarka&id=". $id ."'><img src='$kat/$file' /></a><br><br>";
  12. }
  13. }
  14. closedir($handle);
  15. }
  16.  
  17. ?>


Pomocy!
Go to the top of the page
+Quote Post
szuset
post
Post #2





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 16.10.2006

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


$id < $id + 4; - ten warunek zawsze bedzie prawdziwy
Go to the top of the page
+Quote Post
misieq
post
Post #3





Grupa: Zarejestrowani
Postów: 39
Pomógł: 0
Dołączył: 1.11.2006

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


Ma-nu-al :|
http://pl.php.net/manual/pl/function.readdir.php
Go to the top of the page
+Quote Post
batman
post
Post #4





Grupa: Moderatorzy
Postów: 2 921
Pomógł: 269
Dołączył: 11.08.2005
Skąd: 127.0.0.1




Zamiast bawić się w opendir, readdir, itd polecam

SPL

a w szczególności: RecursiveDirectoryIterator
Go to the top of the page
+Quote Post
f4ngorn
post
Post #5





Grupa: Zarejestrowani
Postów: 43
Pomógł: 0
Dołączył: 7.08.2005

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


Jest lepiej (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) Teraz ladnie dziala, wszystko pikus, tylko zmienna $file nie dziala jak trzeba :/ OCB? File jest zdefiniowany wczesniej niz jest to wymagane... petla wyswietla <img src="xxx/"> zamiast <img src="xxx/yyy.jpg"> Nie zrozumialem bledu z manuala... wydaje mi sie ze skrypt jest dobry :/

@batman
Nie jarze tego SPL (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) Jeszcze za malo siedze w php, ta galeria to moj pierwszy "wiekszy" skrypt.

Ten post edytował f4ngorn 10.11.2006, 21:05:47
Go to the top of the page
+Quote Post
batman
post
Post #6





Grupa: Moderatorzy
Postów: 2 921
Pomógł: 269
Dołączył: 11.08.2005
Skąd: 127.0.0.1




Na temat DirectoryIterator możesz poczytać tutaj, a na temat RecursiveDirectoryIterator tutaj

Warto się zapoznać z SPL, ponieważ klasy te będą rozwijane i mogą stanowić sporą pomoc dla programisty.
Go to the top of the page
+Quote Post
f4ngorn
post
Post #7





Grupa: Zarejestrowani
Postów: 43
Pomógł: 0
Dołączył: 7.08.2005

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


Jezeli zmienna jest ustawiana przed miejscem, w ktorym jest uzyta zmienna uzyta w niej, to nie bedzie wykonywana ta "podzmienna"? Bo juz sam niewiem... skrypt niechce chodzic ani latac (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)
Go to the top of the page
+Quote Post

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: 24.08.2025 - 13:34