Puoi fare cosi.

codice:
<table summary="" border="1"><?   
 $flag = true;
 $link = mysql_connect("", "root", "") or die ("Impossible de se connecter => ".mysql_error());
 mysql_select_db ("test") or die ("Impossible de se connecter => ".mysql_error());  
 $query = "select * from catalogo_categorie order by nome";
 $res   = mysql_query($query) or die(mysql_error());
 while ($array = mysql_fetch_assoc($res)) {
  if ($flag) {
   //------ headers
   $flag = false;
   $th   = array_keys($array);
   $a    = implode("</th><th>",$th);
   $str  = "<th>$a</td>\n";
   print $str;	 
  } // if ($flag) 
  //------ dati
  $a   = implode("</td><td>",$array);
  $str = "<tr><td>$a</td></tr>\n";
  print $str;
 }  // while ($array = mysql_fetch_assoc($res)) ?>
</table>