Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2006
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts

    display images based on last login

    hi,

    i have a image upload system in my site.in admin control panel i can see all the uploaded images with in particular dates
    for example 10-jan-2007 to 20-jan-2007 like this.
    now i want to put a button so that when i click that button it should display only those images that are uploaded after my last login and till to date.how i can do this.any of your help will be greatly appreciated

    thanks
    mrjameer

  • #2
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    In your user/login table, have 2 fields 'lastlogin' and 'previouslogin' that you update when you login.

    PHP Code:
    $today /* however you store dates */;
    $sql "UPDATE users SET previouslogin = lastlogin, lastlogin = {$today} WHERE id = 123"
    Then when you need to display the pictures since your previous login:

    PHP Code:
    $sql "SELECT p.* FROM photos AS p, users AS s WHERE p.date > s.previouslogin WHERE s.id = 123"

  • #3
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,500
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    This is what I came up with. You would then use a cookie to remember
    the last time you viewed the images. See if you can do something with this:

    PHP Code:
    <?php

    //create a timestamp for a particular date.
    //when you view your files, you save today's
    //date in a cookie, so the next time you run
    //this script, it uses the cookie date.

    //the date entered here manually for testing.
    $date=strtotime("05/28/2006");

    // open specified directory where your photos are kept.
    $dir './myphotos';
    $dirHandle opendir($dir);
    while (
    $file readdir($dirHandle)) {

    // if not a subdirectory and if filename contains the string '.jpg' 
    if(!is_dir($file) && strpos($file'.jpg')>0) {
    $ffile=$dir."/".$file;
    $timestamp=filemtime($ffile);

    // if $timestamp is greater than the target date, display it
    if($timestamp >= $date){
    echo 
    $file." -- ".$timestamp." <br>\n";
    }
    }


    // then, you would save today's date in the cookie.
    // so it would always look for the latest photos.
    ?>


  •  

    Posting Permissions

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