E' forse questo il codice che ti da quello che vuoi ottenere?

Codice PHP:
$res mysql_query("select * from $tabella"$conn);
echo 
"<table>";
for (
$i 1$row mysql_fetch_assoc($res); $i++) {
    if (!(
$i 1)) {
        echo 
"<tr><th>Num.</th>";
        foreach (
$row as $key => $value)
            echo 
"<th>$key</th>";
        echo 
"</tr>";
    }
    echo 
"<tr><td>$i</td>";
    foreach (
$row as $value)
        echo 
"<td>$value</td>";
    echo 
"</tr>";
}
echo 
"</table>"