How do i add pictures from a dir into a table(no limit on rows either)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dahvie
    New Member
    • Jan 2010
    • 2

    How do i add pictures from a dir into a table(no limit on rows either)

    ok I need a way cause my source code does not like this. I made it but it doesn't use tables and I want this to use tables instead of how i have this set up. Can someone please help me with this? Here is the current code i have set up for use with this.

    Code:
    <?php
    $path = "upload/";
    $dir_handle = @opendir($path) or die("Unable to open folder");
    
    echo "<title>Image Uploader</title>";
    echo "<form action='uploader.php' method='post' enctype='multipart/form-data'>";
    echo "<div align='center'><label for='file'>Select a file:</label> <input type='file' name='userfile' id='file'></div> <br/>";
    echo "<div align='center'>File types allowed: .jpg .jpeg .bmp .png .gif</div>";
    echo "<div align='center'>Max file size: 2.0 MB</div>";
    echo "<div align='center'><input type='submit' name='submit' value='Upload' /></div>";
    echo "</form>";
    echo "<center><a href='png.php'>Click here </a>to view PNG files</center>";
    echo "<center><u><h2>Uploaded Photos</h></u></center>";
    echo "<center>Pictures open up in a new Tab</center>";
    echo "<center>Click the picture to enlarge</center>";
    $filecount = count(glob("" . $path . "*.*"));
    echo "<center>    </center>";
    echo "<center>Total files in our database is: '$filecount'</center>";
    echo "<center>PNG files are not listed here as they slowed loading counter is right</center>";
    while (false !== ($file = readdir($dir_handle))) {
    if(ereg("(.*)\.(jpg|bmp|jpeg|gif)", $file)){
    echo "<a href='$path$file' target='_blank'><img src='$path$file' alt='$file' width='200' height='200'></img></a>";
    }
    
    
    }
    closedir($dir_handle);
    
    
    ?>
    Last edited by Atli; Jan 21 '10, 08:53 AM. Reason: Fixed the text. All lower-case text without a single punctuation mark makes for a very unpleasant read!
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hey.

    I don't think I'm getting the problem here. It just seems to me like you need to add the HTML for your table around your <a><img></a> tags.

    What exactly is it that you are having trouble with?

    Comment

    • code green
      Recognized Expert Top Contributor
      • Mar 2007
      • 1726

      #3
      I'm guessing this does not render the way you hoped, so you are giving up with <div> and going the <table> root.
      HTML standards frowns upon the use of tables for page layout.
      When the page renders copy and paste the source code to W3C Markup Validation Service.
      If you correct the HTML errors you might just succeed

      Comment

      • dahvie
        New Member
        • Jan 2010
        • 2

        #4
        The problem is when this is displayed it doesn't look right and the pictures get off centered sometimes so i wanted to make a better table then what i have used

        Sorry for the bad english not good in this subject

        Comment

        Working...