| re: How to output from file into table???
matt wrote:
[color=blue]
> I have this bit of code that opens a file, reads it line by line, and
> prints the filename into an image on screen, so i get a big list of
> images on the page.
>
> However I want it to output into a table so I can have 2 photos side by
> side as it goes through, is there any way of manipulating the code to
> output one line into one cell and the next line into the next cell then
> back to the first cell again???
>
> <?
> $data = file('gallery/captions');
>
> foreach ($data as $line)
> {
> list ($q, $a) = explode('|' , trim($line) );
> echo "<img src='gallery/images/$q' height=100><br>";
> echo "$a<br>";
> }
>
> ?>[/color]
Hi,
Just make the table:
<table border=1>
<?
$data = file('gallery/captions');
foreach ($data as $line)
{
list ($q, $a) = explode('|' , trim($line) );
?>
<tr>
<td>
<img src='gallery/images/<?= $q ?>' height=100>
</td>
<td>
<?= $a ?>
</td>
</tr>
<?
}
?>
</table>
Regards,
Erwin Moller |