Forum Moderators: coopster
echo "<table border=\"1\">\n";
while ($row = mysql_fetch_assoc($results)) {
echo "<tr>\n";
foreach ($row as $value) {
echo "<td>\n";
echo $value;
echo "</td>\n";
}
echo "</tr>\n";
}
echo "</table>\n";
Create a Dynamic Table from mysql result [webmasterworld.com] msg 4
$tdcount = 1;
$numtd = 3; // number of cells per row
//display the results in a table
echo "<table border=\"1\">";
while($row = mysql_fetch_array($results)) {
if ($tdcount == 1) echo "<tr>";
foreach ($row as $value) {
echo "<td>$value</td>"; } // display as you like
if ($tdcount == $numtd) {
echo "</tr>";
$tdcount = 1;
} else {
$tdcount++;
}
}
// time to close up our table
if ($tdcount!= 1) {
while ($tdcount <= $numtd) {
echo "<td> </td>";
$tdcount++;
}
echo "</tr>";
}
echo "</table>";