Simple? php help

Discussion in 'Web Design and Development' started by ghostchild, Apr 16, 2009.

  1. ghostchild macrumors 6502

    ghostchild

    Joined:
    Jun 17, 2007
    #1
    Hey all so what I want to do is basically write a php code that pulls all my images from a certain folder filled with images and display them. Can someone write me a simple code that does that?

    Thanks,
    John
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
  3. ghostchild thread starter macrumors 6502

    ghostchild

    Joined:
    Jun 17, 2007
    #3
    well im not looking for anything specific i just want to display the images.
     
  4. &Ingonyama macrumors member

    Joined:
    May 6, 2008
    #4
  5. memco macrumors 6502

    Joined:
    May 1, 2008
    #5
    Barebones (requires PHP5 or later):

    PHP:
    <?php

        $dir 
    "dir";
        
    $result scandir ($dir);
        foreach (
    $result as $file
            {
                if (
    substr(strrchr($file"."), 1) == "jpg")
                        {
                            echo 
    "<img src=\"$file\">";
                        }
            }
    ?>
    Obviously you could modify it to scan for other image types, add links, etc.
     
  6. ghostchild thread starter macrumors 6502

    ghostchild

    Joined:
    Jun 17, 2007
    #6
    ok guys I got this

    PHP:
    <?php 

    $dirname 
    "./images"
    $images scandir($dirname); 
    $ignore = Array(".""..""error_log");
    foreach(
    $images as $curimg){
    if(!
    in_array($curimg$ignore)) {
    echo 
    "<img src='./images/$curimg' />\n";
    }; 
    } * 
    ?> 
    now how do I implement this preloader with it?

    http://davidwalsh.name/mootools-image-preloading-progress-bar
     

Share This Page