Results 1 to 3 of 3

Thread: A little php help/suggestion

  1. #1
    Join Date
    Sep 2008
    Posts
    77
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default A little php help/suggestion

    Hey so I have two folders:

    - Thumbnails
    - Actual Images

    I want to write a php script that does the following...

    <a href="fetch all actual images as a link"><img src="fetch all thumbnails to display"></a>

    Here is my code to fetch all the thumbnails, but don't know how to do the link part...
    PHP Code:
    <?php 

    $dirname 
    "./thumbnails"
    $images scandir($dirname); 
    $ignore = Array(".""..""error_log");
    foreach(
    $images as $curimg){
    if(!
    in_array($curimg$ignore)) {
    echo 
    "<li><img src='./thumbnails/$curimg' /></li>";
    }; 
    } * 
    ?>
    How would I go about doing this?
    Last edited by jzhang1013; 08-28-2009 at 05:10 AM.

  2. #2
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    This should work for you. If the images in the actualImages folder has the same file name as the ones in the thumbs, it's very simple.

    PHP Code:
    <?php 

    $dirname 
    "./thumbnails"
    $images scandir($dirname); 
    $ignore = Array(".""..""error_log");
    foreach(
    $images as $curimg){
    if(!
    in_array($curimg$ignore)) {
    echo 
    '<li>
    <a href="actualImages/'
    .$curimg.'"><img src="./thumbnails/'.$curimg.'" alt="" /></a></li>';
    }; 
    } * 
    ?>
    HTH
    - Josh

  3. #3
    Join Date
    Sep 2008
    Posts
    77
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    wow so simple, thanks man! but do you see any problems with this script and me using the lightbox script to open the photos?

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
  •