help...output images

Discussion in 'PHP' started by unlisted80, Sep 28, 2006.

  1. #1
    Hello

    I have alot images store in one folder and i want to display all images in that folder.

    1. display 25 images each pages
    2. display the thumail or the size 75w x 75h
    3. when the user click on the thumail will display full size image

    i found this script..from celerondude.com however the script only support jpg..i am looking support both jpg and gif or other extension

    thanks advance
     
    unlisted80, Sep 28, 2006 IP
  2. discoverclips

    discoverclips Peon

    Messages:
    491
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    
    if ($dir = @opendir("/tmp")) {
      while (($file = readdir($dir)) !== false) {
       echo "<a href=\"big.php?file=" . $file . "\"><img src=\"" . $file . "\" width=\"75\" height=\"75\"></a>\n";
      } 
      closedir($dir);
    }
    
    
    PHP:
     
    discoverclips, Sep 28, 2006 IP
  3. unlisted80

    unlisted80 Peon

    Messages:
    644
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #3
    First Thank for reply :)

    Second if my folder name "img" so i replace the ("/img")) ? if i do that i will get a blank page

    code:
    Thanks
     
    unlisted80, Sep 28, 2006 IP
  4. harsh789

    harsh789 Member

    Messages:
    29
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #4
    if img folder is relative to the current folder, try removing "/" i.e use ("img") instead of ("/img")

    Also you need to strip out (.) and (..) files.
     
    harsh789, Sep 29, 2006 IP
  5. unlisted80

    unlisted80 Peon

    Messages:
    644
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #5
    sorry i am newbie to php...what you mean by this

     
    unlisted80, Sep 29, 2006 IP
  6. harsh789

    harsh789 Member

    Messages:
    29
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #6
    readdir() will return the . and .. entries

    you can strip out . and ..
    if ($file != "." && $file != "..") {
    echo "<a href=\"big.php?file=" . $file . "\"><img src=\"" . $file . "\" width=\"75\" height=\"75\"></a>\n"; 
    }
    PHP:
     
    harsh789, Sep 30, 2006 IP
  7. unlisted80

    unlisted80 Peon

    Messages:
    644
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #7
    This is work fine :)

    Last question:

    Now i need display 10 image in a row and in 5 col (
     
    unlisted80, Sep 30, 2006 IP
  8. unlisted80

    unlisted80 Peon

    Messages:
    644
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #8
    This is work fine :)

    Last question:

    Now i need to display 10 image in a row and in 5 col (50 image total in one page) everything over that go to another page, and another page and so on...

    Thanks advance
     
    unlisted80, Sep 30, 2006 IP
  9. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #9
    I am in the process of creating an IMAGE upload script, it might just do what you want and you can learn from it.

    Peace,
     
    Barti1987, Oct 1, 2006 IP