Hmm...
it still doesn´t work.
If i echo $retVal i just get the word 'Array' (the same number of times that
the number of files in the directory).
If i echo $file i get the file listing...however, it doesn´t pass on the
content to the rest of my script.
Maybe someone could help me out with the whole script? I downloaded this
from some script archive and it works if i use the list.photos datafile. But
i don´t want to change that file every time a new photo is uploaded.
I am trying to read the directory and use the directory handle listing
instead.
If anyone wants to help me out making this databasedriven instead youre very
welcome :)
<?PHP
$retVal = array ();
//Load Directory Into Array
$handle=opendir('.');
while (false !== ($file = readdir($handle)))
if ($file != "." && $file != ".." && ereg(".jpg",$file)) {
$retVal [count($retVal)] = $file;
echo "$retVal <br>\n";
}
//initialize variables
//$data_file = "list.photos";
$thumbnail_dir = "thumbs/";
$num_rows = 3;
$photos_per_row = 3;
$photos = file($retVal); //$retVal used to be $data_file
$total_photos = sizeof($photos);
$photos_per_page = $num_rows * $photos_per_row;
//check to see if the start variable exists in the URL.
//If not, then the user is on the first page - set start to 0
if(!isSet($start)){
$start = 0;
}
//init i to where it needs to start in the photos array
$i = $start;
$prev_start = $start - $photos_per_page;
$next_start = $start + $photos_per_page;
for ($row=0; $row < $num_rows; $row++){
print("<tr>\n");
for ($col=0; $col < $photos_per_row; $col++){
if($i < $total_photos){
$thumbnail = $thumbnail_dir.trim($photos[$i]);
$thumb_image_size = getimagesize($thumbnail);
$image_size = getimagesize(trim($photos[$i]));
print("<td align=\"center\">
<a
href=\"javascript:photo_open('photo_display.php?photo=".trim($photos[$i])."'
,'".$image_size[0]."','".$image_size[1]."');\"><img src=\"".$thumbnail."\"
".$thumb_image_size[3]." border=\"0\"></a></td>\n");
} else {
print("<td></td>\n");
}
$i++;
}
print("</tr>\n");
}
//Clean up directory array
closedir($handle);
return $retVal;
//end table
?>
> -----Original Message-----
> From: _lallous [mailto:[EMAIL PROTECTED]]
> Sent: den 18 september 2001 13:46
> To: [EMAIL PROTECTED]
> Subject: [PHP] Re: Replacing datafile with array
>
>
> works like a charm....
>
> just initializet the $retVal function...
>
> $retVal = array();
> rest of script here....
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]