View Full Version : Script for Recent Photos
I have a section on my homepage that I want to display the most recent 2 or 3 pics that have been uploaded into my gallery. Does anyone know of a script that does that? Like a "recently uploaded" or "recent update" etc.
Thanks
Ryno
djr33
11-07-2006, 07:57 AM
We can't help you unless we know how they are stored.
You just need a list of the 3 most recently updated photos that updates itself each time one is uploaded.
Or connect to your database and check...
Or.....
We need more info.
The images will probably rest in a folder in the root directory.
Yes, more along the lines of something that updates each time something is uploaded.
Hope this helps.
Ryan
djr33
11-08-2006, 05:42 PM
The conventional way, and the way that makes the most sense, is to use a database.
Setup a PHP system that uploads the file, then stores the url of the file in a database, and then search for the latest three entires in the database.
All stuff easily available with php.
however, it sounds like you're just talking about FTP uploads.
Hmm...
I suppose the only way to do it would be to check the timestamp.
You chould check the last modified time, but that wouldn't do much good if you were using an old picture or something. I think that just using the time the file was created would work. I'm pretty sure that changes when you upload... it doesn't carry the old time from the original file. *Might* depend on the ftp app, though.
The conventional way, and the way that makes the most sense, is to use a database.
Setup a PHP system that uploads the file, then stores the url of the file in a database, and then search for the latest three entires in the database.
All stuff easily available with php.
however, it sounds like you're just talking about FTP uploads.
Hmm...
I suppose the only way to do it would be to check the timestamp.
You chould check the last modified time, but that wouldn't do much good if you were using an old picture or something. I think that just using the time the file was created would work. I'm pretty sure that changes when you upload... it doesn't carry the old time from the original file. *Might* depend on the ftp app, though.
Where could I find the code if I setup a database?
BLiZZaRD
11-10-2006, 08:42 AM
it is a lot simpler than all that... really:
Let's say user has 5 pictures and wants to rotate a new picture every 6 hours.
1.jpg through 5.jpg would be the pic names in this example.
upload all 5 pics to the same directory on the server, lets put them in the folder named "pics"
Step 1: add the php handler to your .htaccess to allow php scripts to be executed on HTML pages:
AddType application/x-httpd-php .html .htm
AddHandler application/x-httpd-php .html .php .htm
upload this .htaccess to your /root level directory.
Step2: open notepad and make a php page to handle all the pictures:
<?php
header("Content-Type: image/jpg");
$a = date('G');
if($a < 6) $file = "1.jpg";
else if($a < 12) $file = "2.jpg";
else if($a < 18) $file = "3.jpg";
else $file = "4.jpg";
readfile($file);
?>
save this as picture.php and upoad it with the picturtes them selves.
Now we have 5 pictures and a picture.php in the folder named "pics"
Step 3: Where ever you want your pictures to be shown add this line to the HTML page:
<img src= "http://yoursite.com/pics/picture.php">
That's it. You canadjust your picture.php to display 2, 3, 10 pictures at a time, and stretch it out to 12 hours, once a day, once a week, etc etc.
No need for a database with this one :D
djr33
11-11-2006, 10:57 AM
That's a random image script, yes? Or... no... but a cycle based on date.
He's asking for "recent" as in recently uploaded.
For a database, look into php and mysql... here's a good tutorial--
http://php-mysql-tutorial.com
note that you need both installed on the server for it to work.
BLiZZaRD
11-11-2006, 11:00 AM
Yes, true, it is based on date, but you can make it work... just change the rotate to days or weeks instead of hours, and when you upload a new pic just change the name in the php file.
I was just giving a non-database option. Simple to do and update once it is in action. :)
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.