i am trying to create a 5 column html table from a list of names stored in a text file which are comma separated.
I have got this far but I am far from a competent coder and need some help please. At the moment its displaying the table in one long column.
<?php
$f = fopen("names.txt", "r");
while (!feof($f)) {
$arrM = explode(",",fgets($f));
$val = current ( $arrM ) ;
print "<table border=1>";
while ( $val )
{
print "<tr> <td> $val </td> ";
$val = next ( $arrM) ;
print "<td> $val </td> </tr> ";
print "\n";
$val = next ( $arrM );
}
print "</table>";
}
?>
Thanks very much in advance
RESOLVED... Heres the code for any Googlers looking for the same help..
<?php
$tdcount = 1; $numtd = 3; // number of cells per row
print "<table>";
$f = fopen("names.txt", "r");
while (!feof($f)) {
$arrM = explode(",",fgets($f));
$row = current ( $arrM );
if ($tdcount == 1)
print "<tr>"; print "<td>$row </td>";
if ($tdcount == $numtd) {
print "</tr>";
$tdcount = 1;
} else {
$tdcount++;
}
}
if ($tdcount!= 1) {
while ($tdcount <= $numtd) {
print "<td> </td>"; $tdcount++;
} print "</tr>";
}
print "</table>";
?>
<tr>tags.