title: Display all MySQL table data in html table
body: <p>I am trying to display a whole <code>mysql</code> table in an html table. So far I have found the below code which works to display fields:</p>
  
  <pre><code>&lt;?php
     $con=mysqli_connect("example.com","peter","abc123","my_db");
     // Check connection
     if(mysqli_connect_errno()) {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
     }
  
     $result = mysqli_query($con,"SELECT * FROM Persons");
  
     echo "&lt;table border='1'&gt;
        &lt;tr&gt;
           &lt;th&gt;Firstname&lt;/th&gt;
           &lt;th&gt;Lastname&lt;/th&gt;
        &lt;/tr&gt;";
  
     while($row = mysqli_fetch_array($result)) {
        echo "&lt;tr&gt;";
        echo "&lt;td&gt;" . $row['FirstName'] . "&lt;/td&gt;";
        echo "&lt;td&gt;" . $row['LastName'] . "&lt;/td&gt;";
        echo "&lt;/tr&gt;";
     }
     echo "&lt;/table&gt;";
  
     mysqli_close($con);
  ?&gt;
  </code></pre>
  
  <p>Is there a way that I can display all columns/rows without having to type all the column names as </p>
  
  <p><code>echo "&lt;td&gt;" . $row['FirstName'] . "&lt;/td&gt;";</code></p>