Page 1 of 1
need help checking and selecting files
Posted: Sat May 11, 2002 5:46 am
by pHaZed
I want to have an image gallery, Nothing special.. except I want to make all the image file names like so img_11-05.gif img_12-05.jpg etc
Where 11 is the date and 05 the month...
I want to display a latest submissions on the gallery index.
Which i was thinking i might need a while loop to gather all in last 5 days...?
Code: Select all
$num= "1";
while($num <= 5)
{
echo "<img src="img...
this is were i get stuck.. how do i get it to display the all the image submitted within the last week...
Any help would be great.
Posted: Sun May 12, 2002 3:01 pm
by pozytron
The main trouble with this is that it's extremely hard to find out what images exist, especially since you have imags of multiple formats, unless you are storing them in a textfile or database once submitted. If you are storing them in a database, it's easy. Just have all the images get uploaded into a single folder and add a TIMESTAMP field. Then, you can use a script that gathers all entries in the database past a certain date (five days ago). The sql would be something like
Code: Select all
"select * from images where date>now()+432000"
Just a suggestion, if it doesn't work, there's alternatives.
BTW, is there only gonna be one image per day? if not, wouldn't the image names be "img01_05_12.jpg"? If so, then you could use a while loop.
Code: Select all
$d=mktime();$file_types=array("jpg","gif","png"); //etc.
for($num=0; $n<5; $num++) {
for($x=0;$x<count($file_types);$x++) { //You might use foreach() if you have PHP4
$file="img_".date("d-m",$d).".".$file_typesї$x];
if (file_exists($file)) echo '<img src="'.$file.'">';
}
$d=$d-86400; //subtract a day
}
thanks
Posted: Tue May 14, 2002 2:41 am
by pHaZed
yea, i got it all working now. I decided to use a db instead. Less trouble
