Need help.... sorting
Posted: Sat Jun 07, 2008 1:22 pm
I am new in php, so I need help. I want to se tup quick gallery on my photo portfolio site, bu i am stuck with sorting. Script is up and running, but it sorts files by alphabetical order, and I want it to sort it by date uploaded on server. Since I am new I am not so shure what or how to do, so need help.
script is:
Before <head>
In head:
and finally in the body:
script is:
Before <head>
Code: Select all
<?php if(isset($_REQUEST['big_image']) and $_REQUEST['big_image']!=''){?>
<?php
$image_title = strtolower($_REQUEST['big_image']);
$image_title = str_replace('_',' ',$image_title);
$image_title = str_replace('.jpg','',$image_title);
?>
<?php }?>
Code: Select all
<?php if(isset($_REQUEST['big_image']) and $_REQUEST['big_image']!=''){?>
<title><?php echo $image_title;?></title>
<?php } else {?>
<title>Quick Photo Gallery</title>
<?php }?>
Code: Select all
<?php if(isset($_REQUEST['big_image']) and $_REQUEST['big_image']!=''){?>
<h1 style="text-transform:capitalize;"><?php echo $image_title;?></h1>
<?php list($image_width, $image_height) = getimagesize($_REQUEST['big_image']); ?>
<div style="border:1px solid #EBEBEB; margin-right:10px; margin-bottom:10px; padding:5px; width:<?php echo$image_width;?>px; display:block; clear:both; text-align:center;"><img src="image.php?file=<?php echo $_REQUEST['big_image'];?>&width=500&height=375" alt="<?php echo $image_title;?>" title="<?php echo $image_title;?>"/></div>
<?php }?>
<?php
if(!function_exists('get_file_extension')){
function get_file_extension($filename) {
$filename = strtolower($filename) ;
$exts = split("[/\\.]", $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts;
}
}
if ($handle = opendir('.')) {
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) {
if(get_file_extension(strtolower($file)) == 'jpg' and $file!= 'no_image.jpg'){
$image_title = strtolower($file);
$image_title = str_replace('_',' ',$image_title);
$image_title = str_replace('.jpg','',$image_title);
echo '<div style="border:1px solid #EBEBEB; margin-right:10px; margin-bottom:10px; padding:5px; width:auto; display:block; float:left;"><a href="'.$file.'"><img border="0" src="image.php?file='.$file.'&width=200&height=60" alt="'.$image_title.'" title="'.$image_title.'"/></a></div>';
}
}
closedir($handle);
}
?>