Connecting Tech Pros Worldwide Help | Site Map

How to output from file into table???

  #1  
Old July 17th, 2005, 11:48 AM
matt
Guest
 
Posts: n/a
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>";
}

?>
  #2  
Old July 17th, 2005, 11:48 AM
Michal Wozniak
Guest
 
Posts: n/a

re: How to output from file into table???


[color=blue]
> <?
> $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]

<?
$data = file('gallery/captions');
echo "<table border=1>";
foreach ($data as $line)
{
list ($q, $a) = explode('|' , trim($line) );
echo "<td><img src='gallery/images/$q' height=100><br>";
echo "$a</td>";
$ee++;
//2 - row
if($ee%2==0) echo "<tr>";


}
echo "</table>";
?>

--
Michal Wozniak



  #3  
Old July 17th, 2005, 11:49 AM
Steve
Guest
 
Posts: n/a

re: How to output from file into table???


Michal Wozniak wrote:[color=blue][color=green]
>><?
>>$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]
>
>
> <?
> $data = file('gallery/captions');
> echo "<table border=1>";
> foreach ($data as $line)
> {
> list ($q, $a) = explode('|' , trim($line) );
> echo "<td><img src='gallery/images/$q' height=100><br>";
> echo "$a</td>";
> $ee++;
> //2 - row
> if($ee%2==0) echo "<tr>";[/color]
Tidier is
if($ee%2==0) echo "</tr><tr>";
[color=blue]
>
> }
> echo "</table>";[/color]
echo "</tr></table>";

Steve[color=blue]
> ?>
>
> --
> Michal Wozniak
>
>
>[/color]
  #4  
Old July 17th, 2005, 11:49 AM
Erwin Moller
Guest
 
Posts: n/a

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
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Display XML Output from SQL Server Terry Holland answers 18 June 1st, 2006 12:45 PM
Using BinaryWrite to output PDF to IE Alec MacLean answers 6 March 31st, 2006 02:15 PM
How to load a Unicode file into the database in the same order as the file order answers 15 July 23rd, 2005 08:46 AM
Read only first 10 lines of a file into an array? deko answers 3 July 17th, 2005 05:20 AM