Dear guys,
I need help in reading a text file and displaying the content in an html table with 2 columns.
mytextfile.txt
value1
value2
value3
value4
value5
I've found this code but it's for mySQL use.
<?php
/
If the count is odd, then add an extra
row to the first column, otherwise, keep
the rows the same.
/
$count = mysql_num_rows($result);
if (($count % 2) & 1) {
$c1 = (int) ($count / 2 + 1);
} else {
$c1 = $count / 2;
}
/
I'm using two loops here because it is slightly faster
than forcing the an if..else construct for every iteration.
*/
$str1 = '';
$str2 = '';
for($i = 0; $i < $c1; $i++) {
$row = mysql_fetch_arry($result)
$str1 .= '<li>' . $row['columnName'] . '</li>';
}
for($j = $c1; $j < $count; $j++) { // Use the $c1 as the base num
$row = mysql_fetch_arry($result)
$str2 .= '<li>' . $row['columnName'] . '</li>';
}
print <<<BLOCK
<table>
<tr>
<td valign="top"><ul>$str1</ul></td>
<td valign="top"><ul>$str2</ul></td>
</tr>
</table>
BLOCK;
?>
Appreciate if you can please help, thanks.