title: Writing the attributes of a database in PHP
body: <p>I am writing an application in which user can enter a database name and I should write all of its contents in table with using PHP.I can do it when I know the name of database with the following code.</p>
  
  <pre><code>$result = mysqli_query($con,"SELECT * FROM course");
  
  echo "&lt;table border='1'&gt;
  &lt;tr&gt;
  &lt;th&gt;blablabla&lt;/th&gt;
  &lt;th&gt;blabla&lt;/th&gt;
  &lt;th&gt;blablabla&lt;/th&gt;
  &lt;th&gt;bla&lt;/th&gt;
  &lt;/tr&gt;";
  
  while($row = mysqli_fetch_array($result))
    {
    echo "&lt;tr&gt;";
    echo "&lt;td&gt;" . $row['blablabla'] . "&lt;/td&gt;";
    echo "&lt;td&gt;" . $row['blabla'] . "&lt;/td&gt;";
    echo "&lt;td&gt;" . $row['blablabla'] . "&lt;/td&gt;";
    echo "&lt;td&gt;" . $row['bla'] . "&lt;/td&gt;";
    echo "&lt;/tr&gt;";
    }
  echo "&lt;/table&gt;";
  </code></pre>
  
  <p>In this example I can show it since I know the name of table is course and it has 4 attributes.But I want to be able to show the result regardless of the name the user entered.So if user wants to view the contents of instructors there should be two columns instead of 4.How can I accomplish this.I get the table name with html.</p>
  
  <pre><code>Table:&lt;input type="text" name="table"&gt;
  </code></pre>
  
  <p>Edit:Denis's answer and GrumpyCroutons' answer are both correct.You can also ask me if you didnt understand something in their solution.</p>