<?php
$mysqli = new mysqli('localhost', 'mpeusr', 'mpe2018pass', 'mpe2018db');
$sql = "SELECT name, ra, de, vmag FROM BSC ORDER BY vmag LIMIT 8";
$result = $mysqli->query($sql);

echo "<table><tr>\n";
while ($finfo = $result->fetch_field())
  echo '<th>'. $finfo->name .'</th>';   // field names
echo '</tr>';
while ($star = $result->fetch_row()) {  // rows with the data
  echo "<tr>\n";
  foreach ($star as $value)
    echo "<td nowrap>$value</td>";
  echo "</tr>\n";
}

echo "</tr>\n";  // end of the table

$result->free();   // clean the data object
$mysqli->close();  // close the server connection
?>
