title: How can I pull Data from an SQL table using PHP inside an HTML
body: <p>I am building a website for myself (learning). I am trying to use .html for the base:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head lang="en"&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;JPeG &amp; Chaos LLP - Repair Status&lt;/title&gt;
      &lt;link rel="stylesheet" type="text/css" href="main.css"&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div class="menubar"&gt;
      &lt;ul&gt;
          &lt;li&gt;&lt;a href="index.html"&gt;Home&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="services.html"&gt;Services&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="status.html"&gt;Repair Status&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="about.html"&gt;About&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="contact.html"&gt;Contact Us&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
  &lt;header&gt;JPeG &amp; Chaos LLP&lt;/header&gt;
  
  //XYZ
  
  &lt;p&gt;
      blah blah blah blah
  &lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Where I put the XYZ, I am wanting to pull a table from mysql and place it in to a table that updates every so many minutes (not concerned about the auto-refresh for now).</p>
  
  <p>I tried adding the following PHP in to my HTML, but it doesn't act like PHP, it just prints the sql scripts :</p>
  
  <pre><code>&lt;?php
  $servername = "localhost";
  $username = "name";
  $password = "pass";
  $dbname = "RepairStatus";
  
  // Create connection
  $conn = new mysqli($servername, $username, $password, $dbname);
  // Check connection
  if ($conn-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error);
  }
  
  $sql = "SELECT id, status, tip, eta FROM WorkOrders";
  $result = $conn-&gt;query($sql);
  
  if ($result-&gt;num_rows &gt; 0) {
      echo "&lt;table&gt;&lt;tr&gt;&lt;th&gt;ID&lt;/th&gt;&lt;th&gt;Status&lt;/th&gt;&lt;th&gt;Time In Progress&lt;/th&gt;&lt;th&gt;Est Time of Completion&lt;/th&gt;&lt;/tr&gt;";
      // output data of each row
      while($row = $result-&gt;fetch_assoc()) {
          echo "&lt;tr&gt;&lt;td&gt;".$row["id"]."&lt;/td&gt;&lt;td&gt;".$row["status"]." ".$row["tip"]."&lt;/td&gt;&lt;td&gt;".$row["eta"]."&lt;/td&gt;&lt;/tr&gt;";
      }
      echo "&lt;/table&gt;";
  } else {
      echo "0 results";
  }
  $conn-&gt;close();
  ?&gt;
  </code></pre>
  
  <p>the website  shows:</p>
  
  <blockquote>
    <p>num_rows > 0) { echo ""; // output data of each row while($row = $result->fetch_assoc()) { echo ""; } echo "</p>
  </blockquote>
  
  <p>and continues through the remainder of the php section of the code.</p>
  
  <p>I did run the full php code on a .php file through the website and it pulls the data just fine :</p>
  
  <p><a href="http://jpegchaos.com/rstatus.php" rel="nofollow">http://jpegchaos.com/rstatus.php</a></p>
  
  <p>Any suggestions on how to do this so I can use my CSS / HTML to format the results?</p>