PHP - how do i echo your result in 4 column table

Asked By Olusegun A. on 12-Jul-10 11:55 AM
hello there,

I want to echo my result from mysql database, i know how to echo it out in 1 column, but this time i want it to be in 3 or 4 columns, how do i do this.

regards
Gayathri S replied to Olusegun A. on 13-Jul-10 01:50 AM
You have to use a while loop along with the table html tag to do this. An example code would be:

<?php
$result=mysql_query("some query");
echo "<table>";
while($val=mysql_fetch_array($result))
{
  echo "<tr>";
  echo "<td>" . $val[0] . "</td>";
  // and so on for all the other columns
  echo "</tr>";
}
echo "</table>";
?>