Well, you know what the column names are going to be before you pull them out so we don't have to get too clever really. Just place the titles outside of the the loop.
<?php
echo("<TABLE BORDER=\"1\" CELLPADDING=\"3\">".
"<tr><td>code</td>\n".
"<td>Maatschappij</td>\n".
"<td>Vertrek</td>\n".
"<td>Aankomst</td>\n".
"<td>Conumptie</td>\n".
"<td>Prijs</td></tr>\n");
while($row=mysql_fetch_array($res)) {
echo("<tr><td>".$row['Code']."</td>\n".
"<td>".$row['Maatschappij']."</td>".
"<td>".$row['Vertrek']."</td>".
"<td>".$row['Aankomst']."</td>".
"<td>".$row['Consumptie']."</td>".
"<td>".$row['Prijs']."</td>".
"</>");
}
echo("</table>");
?>
However, we could be clever and do it like this.
<?php
$table='<table border="1" cellpadding="3"><tr>';
$field_c=mysql_num_fields($res);
for($i=0;$i<$field_c;$i++) {
$table.='<td>'.mysql_field_name($res,$i).'</td>';
}
$table.='</tr>';
while($row=mysql_fetch_row($res)) {
$table.='<tr>';
for($i=0;$i<$field_c;$i++)
$table.='<td>'.$row[$i].'</td>';
$table.='</tr>';
}
$table.='</table>';
?>
With the second method you can add fields to the query and the script will automatically change the dynamics of the table, making your script that little bit more dynamic. This kind of idea can come in very handy when you start building dynamic queries because there is rarely any way of predicting what the output will look like before you get it.
HTH
Bubble