Text to html table?
Posted: Thu Dec 12, 2002 9:01 pm
I'm not even sure what to ask for here. I have several charts, for lack of a better word. They are currently hard coded as tables. One in particular is a TV schedule.
What I would like to do is keep the data in a text file. Then use PHP to pull this info into a correctly formatted table.
I found and modified some code that I thought would do this. However, what it did was lump all field0 items into one td, all field1, etc. I need each line of data to be a tr, with alternating background colors for easier reading.
This is my original page:
http://www.barntowire.com/DerbyTV.shtml
Here is my PHP attempt:
http://www.barntowire.com/newTV2.html
Here is a snippet of the code I used:
<td align="left"><font face="arial,helvetica" size="2"><?
$readfile = file("TVlist.txt");
for ($k=0; $k<=count($readfile)-1; $k++) {
$fields = split("\t",$readfile[$k]);
print("$fields[2]<br>");
}
?>
</font></td>
What is the best way to do something like this? This particular page gets updated rather frequently, usually I get a list of new programs that will go between existing items (to stay chronological). But I also get multi-column lists that need to be coded quickly, so would modify the same code for them.
Thanks!
Janine
What I would like to do is keep the data in a text file. Then use PHP to pull this info into a correctly formatted table.
I found and modified some code that I thought would do this. However, what it did was lump all field0 items into one td, all field1, etc. I need each line of data to be a tr, with alternating background colors for easier reading.
This is my original page:
http://www.barntowire.com/DerbyTV.shtml
Here is my PHP attempt:
http://www.barntowire.com/newTV2.html
Here is a snippet of the code I used:
<td align="left"><font face="arial,helvetica" size="2"><?
$readfile = file("TVlist.txt");
for ($k=0; $k<=count($readfile)-1; $k++) {
$fields = split("\t",$readfile[$k]);
print("$fields[2]<br>");
}
?>
</font></td>
What is the best way to do something like this? This particular page gets updated rather frequently, usually I get a list of new programs that will go between existing items (to stay chronological). But I also get multi-column lists that need to be coded quickly, so would modify the same code for them.
Thanks!
Janine