Results 1 to 8 of 8

Thread: Script for Recent Photos

  1. #1
    Join Date
    Jul 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jul 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Jul 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by djr33
    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?

  6. #6
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    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:

    Code:
    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 Code:
    <?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:

    Code:
    <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
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #8
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    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.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •