www.webdeveloper.com
Results 1 to 3 of 3

Thread: Looping problem on display of images to php table

Threaded View

  1. #1
    Join Date
    Dec 2012
    Posts
    2

    Looping problem on display of images to php table

    I want to display different images in a 5 by 3 table.

    W1 W1 W1
    W2 W2 W2
    W3 W3 W3
    W4 W4 W4
    W5 W5 W5

    Here is my code
    Code:
    $ds ='\image';
    $imagefile = array("EX_W1_01.png", "EX_W1_02.png", "EX_W2_01.png","EX_W3_01.png");
    echo "<pre>"; print_r($imagefile);
    $file = 'blank.png';
    $d = $ds.$file;
    
    echo "<table border = 1 width=\"540px\" cellspacing=\"0px\" cellpadding=\"0px\">";
    for($row=1;$row<=5;$row++){
       echo "<tr>";
    
          for($col=1;$col<=3;$col++){
    
               // echo"<td height=60px>W$row</td>";
               //if()
               echo"<td height=60px>W$row<img border = 1 height = 120 width = 120 src = $d ></td>" .PHP_EOL;
    
          }
       echo "</tr>";
    
    }
    echo "</table>";     
    ?>
    my desired table is to display the image base on the middle file name and blank.png if no name in the array

    EX_W1_01.png | EX_W1_02.png | blank.png |
    EX_W2_01.png | Blank.png | blank.png |
    EX_W3_01.png | Blank.png | Blank.png |
    Blank.png | Blank.png | blank.png |
    Blank.png | Blank.png | blank.png |
    Last edited by jedaisoul; 04-14-2014 at 06:28 AM. Reason: code tags added

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