473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to output from file into table???

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>";
}

?>
Jul 17 '05 #1
3 1699
<?
$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>";
}

?>


<?
$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

Jul 17 '05 #2
Michal Wozniak wrote:
<?
$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>";
}

?>

<?
$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>";

Tidier is
if($ee%2==0) echo "</tr><tr>";

}
echo "</table>"; echo "</tr></table>";

Steve ?>

--
Michal Wozniak

Jul 17 '05 #3
matt wrote:
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>";
}

?>


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
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bob | last post by:
Everybody, I've been doing a lot of on-line research and cannot find any reference to the exact problem I'm having. Let me preface this question with the fact that I'm coming from an Oracle...
2
by: jaydog | last post by:
Hello... I'm new to XSL, and I've written a XSLT file that converts a XML file to HTML format. When viewed in a browser, it appears exactly as I would like. However, if I want to look at the...
5
by: Glenn | last post by:
Hi! Server info - Win2K3 Server +SP1 with 1 GB Memory and 1.5 GB Virtual Memory SQL Server 2000 Enterprise Edition + SP3 running on this. Required result - Create a SQL Script that will...
5
by: Poster | last post by:
I have a script, its outputs are in HTML. It displays perferctly in a browser, however when I view source, it gives me the JS scripts, but I want to view the HTML output. Is there a way I can view...
4
by: laurenq uantrell | last post by:
I'm using the function below to output all of my stored procedures into a text file. Fice, except that the output file does not reflect the names of the stored procedures correctly if the name has...
6
by: Wescotte | last post by:
I'm writing a tiny php app that will log into our bank of america account and retrieve a file containing a list of checks that cleared the previous day. The problem I'm running into is when I...
9
by: tomblower | last post by:
Access 2000 fully updated Three PCs manage data held on a server. They each have a front-end mdb file linked to tables on the server and on each PC. A problem has arisen over the following line...
5
by: vishwa Ram | last post by:
Hi all, I want to replace a particular blocks only not in entire file. But I will give a new output file with replacement. Replacement should not affect other text my $table;...
16
by: Okonita via DBMonster.com | last post by:
Hi all, I am comming along with all this Linus/DB2/scripting business...I am no longer scared of it!! (LOL). But, I need to create a .ksh script that does a REORGCHK and output only tables...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.