title: PDO - Putting all sql data into an html table using prepared statement
body: <p>I want to fetch all the data from my table and display it in an html table but I'm not sure how to do with a prepared statement that will protect me from sql injection.</p>
  
  <p>I've read that it should look something like:</p>
  
  <pre><code>$getPlayers = $db-&gt;prepare("SELECT * FROM Player WHERE name = :name");
  </code></pre>
  
  <p>But I'm not sure how to use the method using 'WHERE' to get all my data from the database.</p>
  
  <p>This is my code so far. It works and gets me all my data but I dont think its secure from sql injection, is it?</p>
  
  <pre><code>$getPlayers = $db-&gt;prepare("SELECT * FROM Player");
  $getPlayers-&gt;execute();
  
  $players = $getPlayers-&gt;fetchAll();
  
  echo "&lt;table&gt;";
  echo "&lt;tr&gt;&lt;th&gt;Name&lt;/th&gt;&lt;th&gt;Games Played&lt;/th&gt;&lt;th&gt;Tries&lt;/th&gt;&lt;/tr&gt;";
  
  
  foreach( $players as $row) {
      echo "&lt;tr&gt;";
      echo "&lt;td&gt;".$row['name']."&lt;/td&gt;";
      echo "&lt;td&gt;".$row['games_played']."&lt;/td&gt;";
      echo "&lt;td&gt;".$row['tries']."&lt;/td&gt;";
      echo "&lt;/tr&gt;";
  }
  
  echo "&lt;/table&gt;";
  </code></pre>