Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Problem ze skryptem, petla sie petli...
f4ngorn
post 7.11.2006, 21:11:09
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 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 7.11.2006, 21:25:30
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 7.11.2006, 21:25:53
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 8.11.2006, 09:02:37
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


--------------------
I would love to change the world, but they won't give me the source code.
My software never has bugs. It just develops random features.
Go to the top of the page
+Quote Post
f4ngorn
post 10.11.2006, 21:03:46
Post #5





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

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


Jest lepiej 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 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 10.11.2006, 21:14:58
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.


--------------------
I would love to change the world, but they won't give me the source code.
My software never has bugs. It just develops random features.
Go to the top of the page
+Quote Post
f4ngorn
post 11.11.2006, 19:58:42
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 sad.gif
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: 19.07.2025 - 10:21