Is this OK ?
$i = 0;
while ($row = mysql_fetch_array($result))
{
$resultset[] = $row;
$columns[] = mysql_fetch_field($result, $i);
}
<
Use mysql_fetch_assoc to get only an associative array and retrieve the column names with the first iteration:
$columns = array();
$resultset = array();
while ($row = mysql_fetch_assoc($result)) {
if (empty($columns)) {
$columns = array_keys($row);
}
$resultset[] = $row;
}
Now you can print the head of your table with the first iteration as well:
echo '';
$columns = array();
$resultset = array();
while ($row = mysql_fetch_assoc($result)) {
if (empty($columns)) {
$columns = array_keys($row);
echo ''.implode(' ', $columns).' ';
}
$resultset[] = $row;
echo ''.implode(' ', $rows).' ';
}
echo '
';