Page 1 of 1

display image with newest date

Posted: Mon Oct 07, 2002 4:33 am
by Verboten
Hey there
I run a gallery site, and on the main index.html of my site I need a script to display the image with the newest date, pulled from a specified directory (where all images from the gallery are stored). Basically showing everyone the last image that has been uploaded and attract users into the gallery. Anyone know where I would start with this? I could also pull the image based on the highest alphabetized name, since the gallery program renames all files in alpha order (ie: aa.jpg, ab.jpg, ac.jpg etc).

Using the filenames seems to be the more reliable way in case i have to alter an image and then reupload it, I wouldnt want it to show on the main page again just because the date had changed by me messin with the pic.
My site is ran on Unix, and php 4.22

I couldnt find anything in the manual or in the archives of this forums.
Thanks for any help or hints

Posted: Mon Oct 07, 2002 4:40 am
by twigletmac
You should have a look at the filesystem functions and specifically the filemtime() function. The directory functions will be useful too.

Mac

Posted: Wed Oct 09, 2002 3:47 am
by Verboten
hmm correct me if im wrong but wouldnt those functions you linked me to, only help me display what the date of the newest file was, and not display the file itself? I dunno im not really sure what the best route to go is.
Thanks

Posted: Wed Oct 09, 2002 3:54 am
by twigletmac
These functions will help you go through a folder and pick out images based on certain criteria (eg. which image was last updated). Of course they won't display the images for you but you will have the image's name that you want to display. To display the file you just need to put that image's name into the IMG tag in HTML:

Code: Select all

echo '<img src="'.$latest_image.'" alt="The last image that was updated" />';
Mac