Klokjis Posted March 23, 2006 Report Share Posted March 23, 2006 (edited) probleema, taada, ka shajaa skriptaa izmet erroru, ka "if (file_exists( "pic/".$i.".jpg")) {" line izpildiishanas laix ir beidzies... (Maximum execution time of 30 seconds exceeded). a kapeec vinjsh tur apraujas?? $count = 0; $i = 1; while ($count < "5") { if (file_exists( "pic/".$i.".jpg")) { echo " <td><img src='pic/".$i.".jpg'></td>"; $i++; $count++; } else { $i++; }; }; Edited March 23, 2006 by Klokjis Link to comment Share on other sites More sharing options...
eglitis Posted March 23, 2006 Report Share Posted March 23, 2006 Vai tik while ($count < "5") nebūs pie vainas - "5" ir string, bet $count - integer. Link to comment Share on other sites More sharing options...
Klokjis Posted March 23, 2006 Author Report Share Posted March 23, 2006 (edited) nu ar while ($count < 5) arii neiet... Edited March 23, 2006 by Klokjis Link to comment Share on other sites More sharing options...
bubu Posted March 23, 2006 Report Share Posted March 23, 2006 eglitis: php pats māk pārvērst tipus (string<->integer). Klokjis: uzzīmē moš blokshēmu savam algoritmam? Uzreiz redzēsi kur vaina (hints: $count++). Link to comment Share on other sites More sharing options...
Klokjis Posted March 23, 2006 Author Report Share Posted March 23, 2006 nu iznaak: a) count = 0 b) count < 5 (Nee - neko nedara; Jaa - turpina c...) c) fails pastaav?! (Nee - saak no b; Jaa - turpina d...) d) palielina count par 1 (count+1) [saak no b]... teoreetiski... izpildaas algoritms. Link to comment Share on other sites More sharing options...
Blitz Posted March 23, 2006 Report Share Posted March 23, 2006 un ja tev ir 4tras bildes... count aizskaita lidz 4 un pec tam pluso klat tikai i, bet cikls iet kamer count < 5, tatad ja neaizskaita lidz 5 tad ari neapstajas... Link to comment Share on other sites More sharing options...
bubu Posted March 23, 2006 Report Share Posted March 23, 2006 nu iznaak:a) count = 0 b) count < 5 (Nee - neko nedara; Jaa - turpina c...) c) fails pastaav?! (Nee - saak no b; Jaa - turpina d...) d) palielina count par 1 (count+1) [saak no b]... teoreetiski... izpildaas algoritms. Nu un kur tev šajā vietā algoritms beidzās? Tas tev nav uzrakstīs. Blokshēmām vienmēr ir sākums un ir beigas taču! Link to comment Share on other sites More sharing options...
Klokjis Posted March 23, 2006 Author Report Share Posted March 23, 2006 tnx. visiem ;))) ieliku $i parametru... kas ir max. un ar to arii beidzaas ;) Link to comment Share on other sites More sharing options...
john.brown Posted March 23, 2006 Report Share Posted March 23, 2006 Nav īsti skaidrs priekš kam tev divi mainīgi: $i un $count. šitā tak vienkāršāk laikam būs: <?php $i = 1; while ($i < 6) { if (file_exists( 'pic/'.$i.'.jpg')) { echo '<td><img src="pic/'.$i.'.jpg"></td>'; } $i++; }; ?> Bez tam pievērs uzmanību pēdiņu izvietojumam... Link to comment Share on other sites More sharing options...
Blitz Posted March 23, 2006 Report Share Posted March 23, 2006 un ja cilvekam ir bildes 1.jpg, 2.jpg, 3.jpg, 9.jpg, 12.jpg ??? Link to comment Share on other sites More sharing options...
john.brown Posted March 23, 2006 Report Share Posted March 23, 2006 Nu, jā, nebij taisnība, pasteidzos... :) Link to comment Share on other sites More sharing options...
Recommended Posts