www.webdeveloper.com
Results 1 to 4 of 4

Thread: Display results in 2 column table

  1. #1
    Join Date
    Jun 2014
    Posts
    2

    Display results in 2 column table

    I'm using some simple PHP to display all images found in a specified image directory. Currently it displays the images in a single column. How would I modify this code to display the results in 2 columns.
    I did not write the code so I'm not sure where to modify it.

    Here is the current code:
    PHP Code:
    <?php
    $folder 
    'currency images/Australia/';
    $filetype '*.*';
    $files glob($folder.$filetype);
    $count count($files);
    echo 
    '<table>';
    for (
    $i 0$i $count$i++) {
        echo 
    '<tr><td>';
        echo 
    '<a name="'.$i.'" href="#'.$i.'"><img src="'.$files[$i].'" /></a>';
        echo 
    '</td></tr>';
    }
    echo 
    '</table>';
    ?>
    Thank you!
    Last edited by NogDog; 06-18-2014 at 10:10 AM. Reason: added [php] tags around code

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,322
    It depends on what order you want them to display:
    Code:
    img1  img2
    img3  img4
    img5  img6
    ...or...
    Code:
    img1  img4
    img2  img5
    img3  img6
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Jun 2014
    Posts
    2
    It doesn't really matter, but probably Img 1 and Img 2 in the second column and so on...

  4. #4
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    715
    It's a simple matter of reading up on html tables and adding the extra td element. Also you could code your contents up a bit easier this way:
    PHP Code:
        echo "<a name='$i' href='#$i'><img src='{$files[$i]}'/></a>"

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles