1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Simple image gallery problem.

Discussion in 'PHP' started by David Raz, Mar 15, 2011.

  1. #1
    The site:
    http://add.imgchan.com

    Script is taking images from the "up" folder. I'm trying to limit 4 images that have been recently uploaded. Also when when they click on the image, i would like them to go to the source of the image.

    For example the picture of the bmw. From the recently uploaded. When the click on it they would go to http://add.imgchan.com/up/a.jpg


    
    <?
    $files = glob("up/*.*");
    for ($i=1; $i<count($files); $i++)
    {
    	$num = $files[$i];
    	echo '<img src="'.$num.'" width="200" height="150" alt="random image">'."&nbsp;&nbsp;";
    	}
    ?>
    
    Code (markup):
    Please help :confused:
     
    David Raz, Mar 15, 2011 IP
  2. asianseekerz

    asianseekerz Member

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #2
    ummmmmmmmmmmmmmm it need something to add code
     
    asianseekerz, Mar 15, 2011 IP
  3. David Raz

    David Raz Active Member

    Messages:
    106
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #3
    I don't understand what you mean.
     
    David Raz, Mar 15, 2011 IP
  4. David Raz

    David Raz Active Member

    Messages:
    106
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #4
    Does anyone have any suggestions? I'm sure it's an easy fix.
     
    David Raz, Mar 15, 2011 IP
  5. joy1986joy

    joy1986joy Member

    Messages:
    189
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    30
    #5
    Hi
    You are trying to get the recently uploaded files. Try to give a time stamp or unique integer id. Then take the last 4 or take the latest 4 time stamp. Hope this will help you.
     
    joy1986joy, Mar 16, 2011 IP
  6. Automagick

    Automagick Greenhorn

    Messages:
    22
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    23
    #6
    You could also read all finles of the folder into an array (glob do it well).
    Then you can do a loop and use filemtime($files[$i]) to get the modification date and save it into a temporary array.

    Then you sort the array, and show the 4 resutls you need.
     
    Automagick, Mar 17, 2011 IP