I wonder if you are asking for this:
echo "<table>";
while ($row = mysql_fetch_assoc($result)) 
{
    echo "<tr>";
    foreach ($row AS $field)
        echo "<td>$field</td>";
    echo "</tr>";
}
echo "</table>";
solved How to get and display all the data of database in php [closed]