I have a data file like so:
Code: Select all
row1col1||row1col2||row1col3||row1col4
row2col1||row2col2||row2col3||row2col4
row3col1||row3col2||row3col3||row3col4
which I want converted into a table and displayed, the relevant section of code is as follows but all it does is make a table with the right number of rows and columns but no data in any of the cells: (have to ignore the crap about colour for the moment, unless I've done it wrong.
Code: Select all
<?php
//extract data from file
$Lines = file("data.txt");
foreach($Lines as $Key => $Val)
{
//explode that data into a new array:
$Data[$Key] = explode("||", $Val);
}
//process data
echo "<table border=\"1\">";
for($R = 0; $R < sizeof($Lines); $R++)
{
if($data[$R][1]==1000){
$colour = "#000000";
}else if($data[$R][1]==100){
$colour = "#000000";
}else if($data[$R][1]==10){
$colour = "#000000";
}else{
$colour = "#FFFFFF";
}
echo "<tr>";
for($C = 0; $C < 4; $C++)
{
echo "<td bgcolor=\"$colour\"> <p>";
echo $data[$R][$C];
echo "</p> </td>";
}
echo "</tr>";
}
echo "</table>";
?>