title: Show data pulled from database, based on html form input and display in html page
body: <p>I have a html page with an input box. I am trying to retrieve data from the database based on that input and send it back to the original html page in the form of a table using php. I created the php in an external file and it was displaying the correct values in the browser but my issue is trying to display the php on the html page. </p>
  
  <p>I enabled my server to parse html files and have put the php within the html file but still was not working. When I entered a value and submit the page reloads but nothing is displayed.</p>
  
  <p>If anyone knows the best way of doing this I would appreciate the advice. I have read numerous threads and none seem to work. </p>
  
  <p>PHP:</p>
  
  <pre><code>&lt;?php
  
  define('DB_NAME', 'database');
  define('DB_USER', 'user');
  define('DB_PASSWORD', 'password');
  define('DB_HOST', 'localhost');
  
  $conn = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
  if (!$conn) {
       die('Could not connect: ' . mysqli_connect_error());
       }
  
  $studentnum = $_POST['studentnum'];     
  
  $sql = "SELECT * FROM test WHERE number LIKE '%$studentnum%'"; 
  $result=mysqli_query($conn, $sql);
  
  echo '&lt;table class="table table-striped table-bordered table-hover"&gt;'; 
  echo "&lt;tr&gt;
        &lt;th&gt;Name&lt;/th&gt;
        &lt;th&gt;Number&lt;/th&gt;
        &lt;th&gt;Floor&lt;/th&gt;
        &lt;th&gt;Room&lt;/th&gt;
        &lt;th&gt;Message&lt;/th&gt;
        &lt;/tr&gt;"; 
  while($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
  {
    echo "&lt;tr&gt;&lt;td&gt;"; 
    echo $row['name'];
    echo "&lt;/td&gt;&lt;td&gt;"; 
    echo $row['number'];
    echo "&lt;/td&gt;&lt;td&gt;";   
    echo $row['floor'];
    echo "&lt;/td&gt;&lt;td&gt;"; 
    echo $row['room'];
    echo "&lt;/td&gt;&lt;td&gt;";   
    echo $row['message'];
    echo "&lt;/td&gt;&lt;/tr&gt;";  
  
  }
  echo "&lt;/table&gt;";  
  
  mysqli_close($conn);
  ?&gt;
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;form action="test.php" method="post"&gt;
              &lt;label&gt;Enter Student Number:&lt;/label&gt;
              &lt;input name="studentnum" type="number" placeholder="Type Here"&gt;
                  &lt;br&gt;
                  &lt;br&gt;
              &lt;input type="submit" value="Enter"&gt;
  
      &lt;/form&gt;
  </code></pre>