bubu Posted March 18, 2005 Report Share Posted March 18, 2005 Tas ir normāli. Šī rindiņa "if ($i<$start) continue;" nodrošina to, lai pie vērtībām, kad $i<$start netiktu drukātas arā tās bildes. Tāpēc pārbaudi $start vērtību pirms while cikla uzsākšanas. Link to comment Share on other sites More sharing options...
barons Posted March 18, 2005 Author Report Share Posted March 18, 2005 Tas ir normāli. Šī rindiņa "if ($i<$start) continue;" nodrošina to, lai pie vērtībām, kad $i<$start netiktu drukātas arā tās bildes. Tāpēc pārbaudi $start vērtību pirms while cikla uzsākšanas. 15180[/snapback] page=1 vish raad ka $start ir 1 2 3 4 5 6 7 8 9 un naakamaas lapaas +9 tas ir page=2 -> 9 page=3 -> 18 u.t.t. Link to comment Share on other sites More sharing options...
bubu Posted March 18, 2005 Report Share Posted March 18, 2005 $start ir 1 2 3 4 5 6 7 8 9wtf? cik tad īstī ir $start? Link to comment Share on other sites More sharing options...
barons Posted March 21, 2005 Author Report Share Posted March 21, 2005 wtf? cik tad īstī ir $start? 15185[/snapback] $start = 0 ! Link to comment Share on other sites More sharing options...
bubu Posted March 21, 2005 Report Share Posted March 21, 2005 $start = 0 ! 15268[/snapback] Pie jebkura $page vērtībās? 0 jābūt tikai, ja $page = 1 Link to comment Share on other sites More sharing options...
barons Posted March 21, 2005 Author Report Share Posted March 21, 2005 Pie jebkura $page vērtībās? 0 jābūt tikai, ja $page = 1 15277[/snapback] Nee pie page=1 $start = 9 ,page=2 $start = 18 u.t.t. Link to comment Share on other sites More sharing options...
barons Posted March 21, 2005 Author Report Share Posted March 21, 2005 Es nomainiiju biski shaadi: $dir=opendir("pic/auto/"); $i = $start+1; //pieveerst uzm. sheit! //print($start."-"); // print($end); while(($fails=readdir($dir)) !=false){ if ( !eregi('(jpg|jpeg)$',$fails) ) continue; //print($i); if ($i<$start) continue; if ($i>$end) break; print("<img src=pic/auto/$fails width=120 height=81 border=1><b>$fails</b> "); if( $i % 3 == 0 ) echo "<br/><br/>"; $i++; } un vish man raad vienas un taas pashas bildes, pirmaas 9! Bet vismaz cikls turpinaas! :blink: Link to comment Share on other sites More sharing options...
bubu Posted March 21, 2005 Report Share Posted March 21, 2005 Loģiski, ka rāda tikai pirmās 9. Takš cikls bildes lasa pēc kārtas, un to continue, kas izlaiž bildes, kuru numurs ($i) ir mazāks (<) par sākuma bildes numuru ($start). Kods dara to, ko tam liek. Link to comment Share on other sites More sharing options...
barons Posted March 21, 2005 Author Report Share Posted March 21, 2005 Loģiski, ka rāda tikai pirmās 9. Takš cikls bildes lasa pēc kārtas, un to continue, kas izlaiž bildes, kuru numurs ($i) ir mazāks (<) par sākuma bildes numuru ($start). Kods dara to, ko tam liek. 15298[/snapback] Tik daudz es ar sapratu :) , bet kaa uzrakstiit lai raad naakamaas? To nu nekaadi nevaru izdomaat <_< Link to comment Share on other sites More sharing options...
Osiris Posted March 21, 2005 Report Share Posted March 21, 2005 (edited) Ja es pareizi sapratu tēmu $totalphotos=mysql_num_rows($result); //vai count(cik ir bildes kopā) $totalpages=ceil($totalphotos/9); // vai cik tur lappuses if (!isset($page)) $page=1; else { $page=round($page); if ($page>=$totalpages) $page=$totalpages; if ($page<=1) $page=1; } Edited March 21, 2005 by Osiris Link to comment Share on other sites More sharing options...
barons Posted March 21, 2005 Author Report Share Posted March 21, 2005 Shaads man ir pilnais kods! $filename = "images.php"; $imagesCount = @file_get_contents('pic/auto/images.txt',r); // sheit nolasa skaitu $page = (int) $_GET['page']; $perPage = 9; //noraad cik buus bildes vienaa lapaspusee $pages = ceil( $imagesCount / $perPage ); //sadal cik buus lapas puses if ($page<1 || $page>$pages) $page = 1; //ja page lielaaks pa noeikto lpp.sk. page ir 1 $start =$perPage * ( $page - 1 ); //apmeeram nojaushu $end =($start+$perPage<$imagesCount) ? $start+$perPage : $imagesCount; // apmeeram nojaushu $dir=opendir("pic/auto/"); $i = $start+1; //print($start."-"); // print($end); while(($fails=readdir($dir)) !=false){ if ( !eregi('(jpg|jpeg)$',$fails) ) continue; //print($i); if ($i<$start) continue; if ($i>$end) break; print("<img src=pic/auto/$fails width=120 height=81 border=1><b>$fails</b> "); if( $i % 3 == 0 ) echo "<br/><br/>"; $i++; } //print($fails); //print($start."-"); //print($end."-"); for ($i = 1; $i<=$pages; $i++) { echo " [<a href='?page=$i'>$i</a>] "; } echo "</center>"; viss itkaa buutu, bet jaanoraad lai cikls turpinaas nevi atkal nolas bilzu mapi no saakuma! Link to comment Share on other sites More sharing options...
Delfins Posted March 21, 2005 Report Share Posted March 21, 2005 viss itkaa buutu, bet jaanoraad lai cikls turpinaas nevi atkal nolas bilzu mapi no saakuma! 15303[/snapback] da loogiski ka nolasiis no saaakuma, tapec ka tev ielikts ir $i = $start + 1; bet jaabut $i= 0; Link to comment Share on other sites More sharing options...
barons Posted March 21, 2005 Author Report Share Posted March 21, 2005 da loogiski ka nolasiis no saaakuma, tapec ka tev ielikts ir $i = $start + 1; bet jaabut $i= 0; 15304[/snapback] Bet kad ir $i=0, paarsleedzot lapu piem. page=2, neraad nevienu bildi! Link to comment Share on other sites More sharing options...
Delfins Posted March 21, 2005 Report Share Posted March 21, 2005 sapratu kur kļūda nomaini šo : if ($i<$start) continue; if ($i>$end) break; ar šo $i = -1; while ( ... ) { $i++; if ($i<$start) continue; if ($i>$end) break; } beigās $i++ izdzēs Link to comment Share on other sites More sharing options...
barons Posted March 21, 2005 Author Report Share Posted March 21, 2005 Ne redz to es ar gribeeju dabuut gatavu :) Bet ir viens bet, neraad 9 bildes, bet gan 10, katraa naakamaa lapaa saak raadiit ar ieprieksheejaas lapas peedeejo bildi <_< Link to comment Share on other sites More sharing options...
Recommended Posts