Last night I was struggling for several hours trying to figure out how to get this working. After many googlings I finally found my answer and modified it to the following:
The $key in the following will be your column title (field) and the $value is the rows value. In the following I will be populating based off one particular row (in this case it has an id of 1).
print "<table border='1'>";
$sql = "SELECT * FROM table_name WHERE id=1";
$result = mysql_query($sql)or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
foreach($row as $key => $value) {
print "<tr><th>" .$key. "</th><td><input type='text' value='" .$value. "' /></td></tr>";
}
print "</table>";
MySQL table:

Resulting PHP/HTML table from code:

