title: Deleting row using PDO Php
body: <p>I am trying to delete a row using PDO but unable to delete the row and am clearly mis understanding something here.</p>
  
  <p>Here is the link that will allow me to delete the row:</p>
  
  <pre><code>&lt;a class="deleteMember" href="actions/delete.php?doc_id="'.$docs['doc_id'].'"&gt;&lt;i class="fa fa-times"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;
  </code></pre>
  
  <p>So it should pass the doc_id from that row to the delete.php file which is below:</p>
  
  <pre><code> &lt;?php
  
      $hostname='localhost';
      $username='******';
      $password='*****';
  
      try {
  
  $dbh = new PDO("mysql:host=$hostname;dbname=dashboardr",$username,$password);
  
  $sql = "DELETE FROM `doc_list` WHERE doc_id != :id_to_delete";
  
  $query = $db-&gt;prepare( $sql );
  
  $query-&gt;execute(array(":doc_id" =&gt; $doc_id));
  
  ?&gt;
  </code></pre>
  
  <p>But once executed I am confronted with a white screen.</p>
  
  <pre><code>So doc_id is defined from here:
  
  try {
  
  $doc_id = $_GET['doc_id'];
  
  $dbh = new PDO("mysql:host=$hostname;dbname=dashboardr",$username,$password);
  $dbh-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // &lt;== add this line
  $sql = "DELETE FROM `doc_list` WHERE doc_id != :id_to_delete";
  
  $query-&gt;bindParam(':id_to_delete', $doc_id, PDO::PARAM_INT);
  $query-&gt;execute();
  
  
  
  if ($query) {
      header ('Location: ../docList.php');
  }
  else{
  }
  
  $dbh = null;
  }
  catch(PDOException $e)
  {
  echo $e-&gt;getMessage();
  }
  </code></pre>
  
  <p>Here is the docList.php file</p>
  
  <pre><code>&lt;?php include 'header.php'; ?&gt;
  
  
  
  &lt;?php 
  
  require_once '../../db_con.php'; 
  
  try{
      // Selecting entire row from doc_list table
      $results = $db-&gt;query("SELECT * FROM doc_list ORDER BY doc_updated DESC");
  
  }catch(Exception $e) {
      echo $e-&gt;getMessage();
      die();
  }
  
  $docs = $results-&gt;fetchAll(PDO::FETCH_ASSOC);
  
  ?&gt;
  
  
  
  &lt;div class="container"&gt;
  
  &lt;br&gt;
  
  &lt;h3 class="subTitle"&gt;&lt;i class="fa fa-file-text"&gt;&lt;/i&gt;&lt;/span&gt; Document List
      &lt;a href="newDoc.php"&gt;&lt;span class="addNew" title="Add New Document"&gt;&lt;i class="fa fa-file"&gt;&lt;/i&gt;&lt;/span&gt;&lt;/a&gt;
      &lt;a href="newEmployee.php"&gt;&lt;span class="addNew" title="Add New Category"&gt;&lt;i class="fa fa-tag"&gt;&lt;/i&gt;&lt;/span&gt;&lt;/a&gt;
  &lt;/h3&gt;  
  
  
  
      &lt;span class="trow"&gt;
          &lt;span class="tableHeadersLarge"&gt;Doc Title&lt;/span&gt;
          &lt;span class="tableHeadersMed"&gt;Created Date&lt;/span&gt;
          &lt;span class="tableHeadersMed"&gt;Last Updated&lt;/span&gt;
          &lt;span class="tableHeadersSmall"&gt;&lt;/span&gt;
      &lt;/span&gt;
  
  
  
  &lt;?php
  
      foreach($docs as $docs){
          echo
          '&lt;span class="trow"&gt;
              &lt;span class="tableHeadersLarge"&gt;&lt;a href="docEdit.php?doc_id='.$docs["doc_id"].'"&gt;'.$docs["doc_title"]. '&lt;/a&gt;&lt;/span&gt;
              &lt;span class="tableHeadersMed date"&gt;'.$docs["doc_created"].'&lt;/span&gt;
              &lt;span class="tableHeadersMed date"&gt;'.$docs["doc_updated"].'&lt;/span&gt;
              &lt;span class="tableHeadersSmall"&gt;
              &lt;a class="editMember" href="docEdit.php?doc_id='.$docs["doc_id"].'"&gt;&lt;i class="fa fa-cogs"&gt;&lt;/i&gt;&lt;/a&gt;
              &lt;a class="deleteMember" href="actions/delete.php?doc_id='.$docs["doc_id"].'"&gt;&lt;i class="fa fa-times"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;
          &lt;/span&gt;';
      }
  ?&gt;
  
  
  
  &lt;/div&gt;
  </code></pre>