read dir

You can leave a response at the bottom of this page.

Gut für das junkish buttons.piry.net, weil ich nicht eine Datenbank benutzen wollte,
ich mußte verwenden wann, um alle Akten in einem Heft zu erhalten…

Ich möchte sie auf Seiten aufspalten…, also sind sie 100 auf jeder Seite zum Beispiel…

und ich tat dies:

<?php
//setam variabilele
$gogu = "";
$nr_pag = "";
if( isset($_GET['page']) && is_numeric($_GET['page']) && 0 < $_GET['page'] && $_GET['page'] <= $nr_pag )
$page = $_GET['page'];
if ( $handle = opendir('/ceva') ) {
   /* Aici facem un loop */
   $i = 0;
   while ( false !== ($file = readdir($handle)) ) {
       		if( isset($page) ){ 
				$start = ($page*100)-100; 
				$stop = $start + 100;
			} 
	   		if( strlen($file) > 2 ){ // verific daca ... nothing ... ingreunez si eu codul domne
	   			if($i >= $start && $i <= $stop){
					if( $i % 4 == 0) $gogu .= "<br />"; // las un rand liber
	   				$gogu .= "<img src=\"x/".$file."\" alt=\"".substr($file, 0, strlen($file)-4)."\" />\n"; 
					//scot extensia si punctul de la extensie
	   			}
			$i++;
	   		}
   }
   closedir($handle);
}
echo $gogu;
?>

–The Pirahna (aka Piry)

One Response to “read dir”

  1. add Says:

    nice… mergea pus 100 ala intr-o variabila, la fel si 4 sa le asezi repede cum vrea muschii tai.

Please click here to comment.