Braiens Posted April 25, 2004 Report Share Posted April 25, 2004 tipa doma tada ka ir file sort... un aiz katra treša faila vajadzētu <br /> Scripts: <? if ($handle = opendir('img')) { while (false !== ($file = readdir($handle))) { $size = getimagesize('img/'.$file); $img_w = $size[0] / 3; $img_h = $size[1] / 3; echo '<a href="img/'.$file.'"><img src="img/'.$file.'" width="'.$img_w.'" height="'.$img_h.'" border="0" /></a><br />'; } closedir($handle); } ?> Link to comment Share on other sites More sharing options...
Aleksejs Posted April 25, 2004 Report Share Posted April 25, 2004 Ir skaists operators "%", kas nozīmē dalīšanu pēc moduļa: 1 % 3 = 1 2 % 3 = 2 3 % 3 = 0 4 % 3 = 1 19 % 3 = 1 29 % 3 = 2 Izmantojot šo operatoru, tu vari nedaudz paštukojot, izdomāt realizāciju ;) Link to comment Share on other sites More sharing options...
Braiens Posted April 25, 2004 Author Report Share Posted April 25, 2004 Ir skaists operators "%", kas nozīmē dalīšanu pēc moduļa:1 % 3 = 1 2 % 3 = 2 3 % 3 = 0 4 % 3 = 1 19 % 3 = 1 29 % 3 = 2 Izmantojot šo operatoru, tu vari nedaudz paštukojot, izdomāt realizāciju ;) ja bet kur likt to % ? /me tik macās :0 Link to comment Share on other sites More sharing options...
Aleksejs Posted April 25, 2004 Report Share Posted April 25, 2004 Man ļoti negribās tā vienkārši rakstīt priekšā kodu. Tas nav pedagoģiski pareizi ;) Ideja ir šāda: tu ievies tajā while ciklā kas tev jau ir vēl vienu mainīgo - skaitītāju, kuru katru reizi palielini par vienu. Cikla beigās pārbaudi, vai šī skaitītāja atlikums pēc moduļa 3 ir vienāds ar 2, ja ir, tad izdrukā to <br>. Mainīgais ir jānoinicializē, kā nulle pirms while cikla. Link to comment Share on other sites More sharing options...
Braiens Posted April 25, 2004 Author Report Share Posted April 25, 2004 Cik saprotu ir jabut: $mainigais_sk = "0"; un vel k-kur ir jaieliek: $mainigais++; ja ? Link to comment Share on other sites More sharing options...
Braiens Posted April 25, 2004 Author Report Share Posted April 25, 2004 Blaa tik gruti pateikt ? Link to comment Share on other sites More sharing options...
Dzh Posted April 25, 2004 Report Share Posted April 25, 2004 offtopic: nūū.. paskatoties uz Braiena jautājumiem, negribas jau man gaudot te.. bet imHo vispirms ir jāiemācās vispārējie programmēšanas principi un algoritmi, un tad tikai ķerties klāt PHP Link to comment Share on other sites More sharing options...
Aleksejs Posted April 25, 2004 Report Share Posted April 25, 2004 Violence is not the answer. Ja tu domā ka ar lamuvārdu iesaistīšanu vienkāršos paplašinātos teikumos būs kas līdzēts, tad "think again". Domāju, ka gribi mācīties... Laikam biju kļūdījies.... <? if ($handle = opendir('img')) { $skaits = 0; while (false !== ($file = readdir($handle))) { $size = getimagesize('img/'.$file); $img_w = $size[0] / 3; $img_h = $size[1] / 3; echo '<a href="img/'.$file.'"><img src="img/'.$file.'" width="'.$img_w.'" height="'.$img_h.'" border="0" /></a><br />'; if (($skaits % 3) == 2){ echo '<br>'; } $skaits = ($skaits + 1) % 3; } closedir($handle); } ?> P.S. Atrodi labu grāmatu par programmēšanu kā tādu. Un palasi to... Link to comment Share on other sites More sharing options...
Braiens Posted April 25, 2004 Author Report Share Posted April 25, 2004 Paldies Link to comment Share on other sites More sharing options...
bubu Posted April 26, 2004 Report Share Posted April 26, 2004 Braiens lielais nethackeris! ;) Link to comment Share on other sites More sharing options...
rumpels Posted April 29, 2004 Report Share Posted April 29, 2004 <html> <head> <title>Foto</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script language=JavaScript> <!-- function atverlogu(url) { open(url, "logs", "top=0, left=0, width=645, height=435,scrollbars=no,resizable=yes,toolbar=no,"); } // --> </SCRIPT> <STYLE> A:link { font-family: Verdana, Georgia, Arial; font-size: 11px; color: #000000; font-weight: bold; text-decoration: underline; } A:active { font-family: Verdana, Georgia, Arial; font-size: 11px; color: #000000; font-weight: bold; text-decoration: underline; } A:visited { font-family: Verdana, Georgia, Arial; font-size: 11px; color: #000000; font-weight: bold; text-decoration: underline; } A:hover { font-family: Verdana, Georgia, Arial; font-size: 11px; color: #FFFFFF; font-weight: bold; text-decoration: none; } </STYLE> </head> <body bgcolor="#DBD9D2"> <table border="0" cellpadding="5" cellspacing="1" align="center" bgcolor="#7C7C7C"> <? //uzrakstam funkciju lai mes varetu kā komentāru bildei izmantot faila nosaukumu bez paplašinājuma function swapext($filename){ $sadalam = explode('.', $filename); $nosaukums=$sadalam[0]; $tips=$sadalam[1]; $izvade=$nosaukums; return $izvade; } define( "SIZE" , 100 );//nodefinējam platumu bildei define( "COLNUM" , 4 );//nodefinejam cik kollonas bus bildes $dir = ($HTTP_GET_VARS['dir'])?($HTTP_GET_VARS['dir']):".";//nodefinejam direktoriju no kuras nolasisim failus $dd = opendir($dir); //meklejam un aptaisa bildes for( $i = 0; $filename = readdir($dd); ){ if( is_file("$dir/$filename") ){ if( $imgSize = getImageSize("$dir/$filename") ){ $comments = swapext($filename); $w0 = $imgSize[0]; $h0 = $imgSize[1]; $imgType = $imgSize[2]; $ratio = $w0 / $h0; if( $ratio > 1 ){ $w1 = SIZE; $w2 = SIZE + 10; $h1 = ( SIZE * $h0 ) / $w0; } else{ $w1 = ( SIZE * $w0 ) / $h0; $h1 = SIZE; } if( ! ( $i % COLNUM ) ){ echo "\n<tr>\n"; } ?> <td valign="top" align="center" width="<?= "$w2" ?>" style='background-color:#BBB7AA' onMouseOver='javascript:this.style.backgroundColor="#D96C00"' onMouseOut='javascript:this.style.backgroundColor="#BBB7AA"'> <a href="javascript:atverlogu('<?= "$dir/$filename" ?>')" target="_self" Title="<?= "*.$comments.*" ?>"> <img src="<?= "$dir/$filename" ?>" style="border: 1px solid #000000; width:<?= $w1 ?>;height:<?= $h1 ?>;"><br><?= "$comments" ?></a> </td> <? $i++; if( ! ( $i % COLNUM ) ){ echo "\n</tr>\n"; } } } } closedir($dd); ?> </table> </body> </html> Link to comment Share on other sites More sharing options...
Recommended Posts