www.webdeveloper.com
Results 1 to 3 of 3

Thread: Return results into a table

Hybrid View

  1. #1
    Join Date
    Mar 2005
    Location
    Western USA
    Posts
    194

    Return results into a table

    I have a folder that has a bunch of images. Then I have a script to view the images of that folder, it puts the images one by one on top of each other along with details about the image. I'd like to put the images into tables and have 2 or 3 images per row. I'm not sure how to do that?

    PHP Code:
    $search $num;  //$num is the search for image with a specific number
    $dir "savedImage/";
    $files scandir($dir);
    foreach(
    $files as $$key=>$value){if(stripos($value$search) !== false){                 $array_of_images[] = $value;
    }
    }
     {       
      foreach(
    $array_of_images as $value)     
                {   echo 
    "<a href='savedImage/".$value."' target='blank'>"$value ."'<br><img src=./savedImage/" $value " width=300></a><br><br>";         
            }


  2. #2
    Join Date
    Aug 2012
    Posts
    155
    Firstly it would be much better to use CSS instead of a table but to answer your question I will use a table layout for you

    PHP Code:
    <?php
    $search 
    $num;  //$num is the search for image with a specific number
    $dir "savedImage/";
    $files scandir($dir);
    foreach(
    $files as $$key=>$value) { 
        if(
    stripos($value$search) !== false) {
            
    $array_of_images[] = $value;
        }
    }
    $num_images count($array_of_images);
    ?>
    <table>
        <tr>
            <?php
                
    foreach($array_of_images as $value) { ?>
                    <td><a href="savedImage/<?php echo $value?>" target='_blank'><?php echo $value?><br>
                        <img src=./savedImage/<?php echo $value?> width=300></a>
                    </td>
                <?php if ($count %== && $count $num_images) { ?>
                    </tr>
                    <tr>
                <?php } elseif ($count == $num_images) { ?>
                    </tr>
            <?php $count++; } ?>
    </table>

  3. #3
    Join Date
    Mar 2005
    Location
    Western USA
    Posts
    194
    Thank you! I appreciate it.

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