0

Hello everyone,

I have a code to display images in a table for a specific ticket. I am needing the table to be 4 columns wide then repeat until there is no more images to show.

Here is my code:

<?php
$folder = "images/ticket_images/".$_REQUEST['ticketid']."/";
$filetype = '*.*';
$files = glob($folder.$filetype);
echo '<table><tr>';
for ($i=0; $i<count($files); $i++) {
    echo '<td>';
    echo '<a name="'.$files[$i].'" href="'.$files[$i].'"><img width="100" height="100" src="'.$files[$i].'" /></a>';

    echo '</td>';
}
echo '</tr></table>';
?>

Any help would be great.

Thanks,
Patrick

Edited by patk570

2
Contributors
3
Replies
34
Views
3 Years
Discussion Span
Last Post by patk570
0

I tried this, but its not working.

    <?php
    $col =0
    $folder = "images/ticket_images/".$_REQUEST['ticketid']."/";
    $filetype = '*.*';
    $files = glob($folder.$filetype);
    echo '<table><tr>';
    for ($i=0; $i<count($files); $i++) {
    $col++
    echo '<td>';
    echo '<a name="'.$files[$i].'" href="'.$files[$i].'"><img width="100" height="100" src="'.$files[$i].'" /></a>';
    echo '</td>';
    if($col % 4) print '</tr><tr>';
    }else{

    echo '</tr></table>';
    }
    ?>
0

I think i got it now.

<table width="100%" cellpadding="5" cellspacing="5"><tr>
              <?php
$cols=4;              
$folder = "images/ticket_images/".$_REQUEST['ticketid']."/";
$filetype = '*.*';
$files = glob($folder.$filetype);

for ($i=0; $i<count($files); $i++) {
$cols++;
    echo '<td align="center">';
    echo '<a name="'.$files[$i].'" href="'.$files[$i].'"><img width="100" height="100" src="'.$files[$i].'" /></a><br><span style=" font-size:8px; color:#339;"><a href="ticketdetails.php?ticketid='.$_REQUEST['ticketid'].'&amp;removepic=1&filename='.substr($files[$i],strlen($folder),strpos($files[$i], '.')-strlen($folder)).'.'.end(explode('.', $files[$i])).'">Delete</a></span>';
    echo '</td>';
    if ($cols % 4 == 0) {
        echo '</tr><tr>';
}
}
?>
</tr></table>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.