barons Posted March 17, 2005 Report Share Posted March 17, 2005 Kā shim kodam noraadiit lai raada tikai jpg failus? Un kaa sadaliit lai raada pa noteiktam rindu sakaitam? $dir=opendir("pic/auto/"); $i = 1; while(($fails=readdir($dir)) !=false){ if($fails!='.' && $fails!='..') { print("<img src=pic/auto/$fails width=120 height=81 border=1> "); if(!($i % 4)) { echo "<br/><br/>"; } $i++; } } Shodien ir tikai otraa diena kad ko meeginu uztaisiit taapeec luudzu neraaties :unsure: Link to comment Share on other sites More sharing options...
рпр Posted March 17, 2005 Report Share Posted March 17, 2005 if()a pieliec veel 3. paarbaudi http://lv.php.net/manual/en/function.mime-content-type.php Link to comment Share on other sites More sharing options...
barons Posted March 17, 2005 Author Report Share Posted March 17, 2005 if()a pieliec veel 3. paarbaudi http://lv.php.net/manual/en/function.mime-content-type.php 15115[/snapback] sorry, nepieleca :( Link to comment Share on other sites More sharing options...
Delfins Posted March 17, 2005 Report Share Posted March 17, 2005 Kā shim kodam noraadiit lai raada tikai jpg failus?Un kaa sadaliit lai raada pa noteiktam rindu sakaitam? $dir=opendir("pic/auto/"); $i = 1; while(($fails=readdir($dir)) !=false){ if($fails!='.' && $fails!='..') { print("<img src=pic/auto/$fails width=120 height=81 border=1> "); if(!($i % 4)) { echo "<br/><br/>"; } $i++; } } Shodien ir tikai otraa diena kad ko meeginu uztaisiit taapeec luudzu neraaties :unsure: 15114[/snapback] if ( !eregi('(jpg|jpeg)$',$fails) ) continue; PS : par rindu skaitam nesapratu... tipa pa lappaspusēm ? Link to comment Share on other sites More sharing options...
hu_ha Posted March 17, 2005 Report Share Posted March 17, 2005 if($fails!='.' && $fails!='..') { pieliec klāt ar && trešo pārbaudi, t.i., vai nu рпр norādīto mime type vai arī vienkārši meklē paplašinājumu jpg if($fails!='.' && $fails!='..' && substr($fails,strlen($fails)-4,4)==".jpg") { var būt kļūda ar no-līdz vērtībām, to skaties pats.. Link to comment Share on other sites More sharing options...
barons Posted March 17, 2005 Author Report Share Posted March 17, 2005 Jaa es domaaju pa lapaspuseem! un paldies shobriid raada tikai bilzu failus :D Link to comment Share on other sites More sharing options...
Venom Posted March 17, 2005 Report Share Posted March 17, 2005 att. uz pēdējo piemēru: $opt['img_ext']=array('.jpg','.jpeg','.gif','.png'); if (in_array(strtolower(strrchr($item,'.')),$opt['img_ext'])) //image Link to comment Share on other sites More sharing options...
Delfins Posted March 17, 2005 Report Share Posted March 17, 2005 Jaa es domaaju pa lapaspuseem! un paldies shobriid raada tikai bilzu failus :D 15119[/snapback] nu visprastaakaa matemaatika $imagesCount = @ file_get_contents('images.count'); // labāk noindeksēt direktoriju un glabāt failā bilžu skaitu kā arī nosaukumus $page = (int) $_GET['page']; $perPage = 10; $pages = ceil( $imagesCount / $perPage ); if ($page<1 || $page>$pages) $page = 1; $start = $perPage * ( $page - 1 ); $end = ($start+$perPage<$imagesCount) ? $start+$perPage : $imagesCount-1; for ($i=$start; $i<$end; $i++ ) { // $img = $images[$i]['name']; ... } pages linkus domaju pats uztaisiisi Link to comment Share on other sites More sharing options...
barons Posted March 17, 2005 Author Report Share Posted March 17, 2005 Delfins <- Noteikti linkus uztaisiitu, ja tikai saprastu kur man jaaiegruuz tavs raxstiitais kods :( Link to comment Share on other sites More sharing options...
Delfins Posted March 17, 2005 Report Share Posted March 17, 2005 Delfins <- Noteikti linkus uztaisiitu, ja tikai saprastu kur man jaaiegruuz tavs raxstiitais kods :( 15122[/snapback] tas kas izvada bildes... indeksatoru taisi atsevišķā failā.. un saglabā images masīvu kā serializētu stringu (cerams tev tur nav daudz bildes) indexdir.php $dh = opendir($dir); while ( $file = readdir($dh) ... ) { .... $images[] = $file; } fwrite( fopen($dir.'/images.cache',w), serialize($images) ); images.php?page=xx $images = unserialize( file_get_contents($dir.'/images.cache') ); // .. tas pats kas iepriekšējā postā.. Link to comment Share on other sites More sharing options...
Delfins Posted March 17, 2005 Report Share Posted March 17, 2005 nu aptuveni taa... simple crap :) Link to comment Share on other sites More sharing options...
barons Posted March 17, 2005 Author Report Share Posted March 17, 2005 Man ir 86 bildes un skaits var palielinaaties!!! :unsure: Link to comment Share on other sites More sharing options...
Delfins Posted March 17, 2005 Report Share Posted March 17, 2005 Man ir 86 bildes un skaits var palielinaaties!!! :unsure: 15127[/snapback] 1.) nu tad noindeksējam un glabājam iekš DB. nekas jau nemainās... vienīgais ka tikai iegūsi, ka SQL-am var norādīt OFFSET ($start, $end) 2.) indeksējam _tikai_ bilžu skaitu. un tad $i = 0; while ( $file ... ) { // pārbaudes if ($i<$start) continue; if ($i>$end) break; print "... $file ..."; $i++; } PS: 2. nav optimālāks... bet ja nav DB... Link to comment Share on other sites More sharing options...
barons Posted March 17, 2005 Author Report Share Posted March 17, 2005 Es laikamsaieshu sviestaa nekas man nesanaak :blink: Link to comment Share on other sites More sharing options...
Delfins Posted March 17, 2005 Report Share Posted March 17, 2005 Es laikamsaieshu sviestaa nekas man nesanaak :blink: 15129[/snapback] tikmēr nesāksi pats domāt par konkrētas lietas realizēšanu tev nekad nekas neizdosies. Link to comment Share on other sites More sharing options...
Recommended Posts