title: Filling an HTML Table with Data from MySQL using PHP
body: <p>I've tried all day to get this stupid page to work, and I can't figure it out. I'm trying to get info from a table to show up in a table in a php file.</p>
  
  <pre><code>if (!mysql_connect($servername, $username, $password))
    die("Connection failed: ");
  
  if (!mysql_select_db($dbname))
    die("Can't select database");
  
  $result = mysql_query("SELECT problem_id, machine_id, description FROM tbl_problem");
  
  if (!$result)
  {
    die("Query to show fields from table failed");
  }
  
  $fields_num = mysql_num_fields($result);
  echo "&lt;table class='table table-hover'&gt;&lt;tr&gt;&lt;th&gt;Problem ID&lt;/th&gt;&lt;th&gt;Machine Number&lt;/th&gt;&lt;th&gt;Problem Description&lt;/th&gt;&lt;th&gt;     &lt;/th&gt;&lt;/tr&gt;";
  
  while($row = mysql_fetch_row($result))
  {
    echo "&lt;tr&gt;&lt;td&gt;" . $row['problem_id']. "&lt;/td&gt;&lt;td&gt;" . $row['machine_id']. "&lt;/td&gt;&lt;td&gt;" . $row['description']. "&lt;/td&gt;&lt;td&gt;&lt;button type='button' class='btn btn-danger'&gt;Resolved?&lt;/button&gt;&lt;/td&gt;&lt;/tr&gt;";
  }
  echo "&lt;/table&gt;";
  </code></pre>
  
  <p>I've used several websites to try and get this to work, but nothing seems to be working. If syntax is really out of whack, it's because I'm modelling it after everything I've seen similar to what I'm trying to do.</p>
  
  <p>What it should do, is if the table "tbl_problem" has data in it, display a table on the website that shows the Problem ID, Machine ID, and Description as well as a button to the right of that which allows you to delete the row from "tbl_problem" (the button is there as a placeholder right now, I don't have code for it to actually delete yet, but if someone wanted to point me in the right direction with that, I'd be much obliged!). </p>
  
  <p>When I run it, I get no table, and instead see the following: </p>
  
  <blockquote>
    <p>Problem IDMachine NumberProblem Description "; while($row = mysql_fetch_row($result)) { echo "" . $row['problem_id']. "" . $row['machine_id']. "" . $row['description']. ""; } echo "[The Resolved? button displays properly here]"; /<em>else { echo "There are no problems! :)"; }</em>/ ?></p>
  </blockquote>