title: How to make a sqli select query result display in an html table without defined columns
body: <p>I want to display the results of my select query on my webpage in a table, however the code im using at the moment uses a pre-defined set of columns. My code is this:</p>
  
  <pre><code>   $result= mysqli_query($con,"SELECT * FROM Customers where First_name = '$specFirstName'");
  
  echo "&lt;table border=\"1px solid black\" width=\"80%\"&gt;&lt;tr&gt;&lt;th&gt;Customer ID&lt;/th&gt;&lt;th &gt;First Name&lt;/th&gt;&lt;th&gt;Last Name&lt;/th&gt;&lt;/tr&gt;" ;
  while($row = mysqli_fetch_array($result)){
     echo "&lt;tr&gt;&lt;td style=\"text-align:center;\"&gt;". $row[('CustomerID')] . "&lt;/td&gt;&lt;td style=\"text-align:center;\"&gt;".$row[('First_name')]."&lt;/td&gt;&lt;td style=\"text-align:center;\"&gt;".$row[('Last_name')];
    echo "&lt;/td&gt;&lt;/tr&gt;";
    }
    echo "&lt;/table&gt;"
  </code></pre>
  
  <p>Now, How can I do the same, but use the database headers in an automatically generated table? Can I also use this method to allow the user to specify the required columns in the query?
  Many thanks,
  Tommy</p>