MySql result to table (with header)

echo '<table>';
$request = "SELECT id, title, name, adr, ulf FROM truc";
$result  = mysql_query($request);
echo '<tr>';
for($i = 0; $i < mysql_num_fields($result); $i++) {
	echo '<td>';
	echo mysql_field_name($result,$i);
	echo '</td>';
}
echo '</tr>';
while($line = mysql_fetch_assoc($result)){
	echo '<tr>';
	foreach ($line as $item) {
		echo '<td>';
		echo $item;
		echo '</td>';
	}
	echo '</tr>';
}
echo '</table>';
  • At last! Someone with real existrpee gives us the answer. Thanks!