title: MySQL DELETE statement not deleting rows
body: <p>The code below is how I am removing data from my database. The user selects titles he wants to remove and then the query should delete those rows. Unfortunately, that isn't working.</p>
  
  <p>I have made sure the DELETE query works by using it in PhpMyAdmin and MySQL Workbench, but for some reason the PHP code I'm coding is not allowing the deletes to work.</p>
  
  <pre><code>&lt;?php
      session_start();
      require ("../login.php");
  
      if (!isset($_SESSION['user'])) 
          header('Location: ../index.php');
  
      include ("header.php");
      include ("subnav.php");
  ?&gt;
  
      &lt;h2&gt;Current Subscriptions&lt;/h2&gt;
  
      &lt;?php
  
      $user_id = $_SESSION['user'];
  
      if (isset($_POST['submit'])) {
          foreach($_POST["titles"] as $title) {
              $stmt = $db-&gt;prepare("DELETE FROM subscriptions WHERE user=:user AND title=:title)");
              $stmt-&gt;bindValue(':user', $user_id, PDO::PARAM_INT);
              $stmt-&gt;bindValue(':title', $title, PDO::PARAM_INT);
              $stmt-&gt;execute();
          }
          echo '&lt;p&gt;Thank you! Your changes have been made!&lt;/p&gt;';
      }
      else {
          $stmt = $db-&gt;prepare
              ("SELECT t.id, t.publisher, t.title
              FROM titles t
                  JOIN subscriptions s
                      ON t.id = s.title
              WHERE s.user=:user
              ORDER BY t.id");
  
          $stmt-&gt;bindValue(':user', $user_id, PDO::PARAM_STR);
          $stmt-&gt;execute();
          $rows = $stmt-&gt;fetchAll();
          $num_rows = count($rows);
          if ($num_rows == 0)
              echo 'You are not currently subscribed to any titles.';
          else {
              ?&gt;
              &lt;form action="" method="post"&gt;
              &lt;?php   
              foreach($rows as $row) 
                  echo '&lt;input type="checkbox" name="titles[]" value="' . $row['id'] . '"&gt;' . $row['publisher'] . ' - ' . $row['title'] . '&lt;br&gt;';
              ?&gt;
              &lt;input type="submit" value="Update" name ="submit" id="submit"&gt;
                  &lt;/form&gt;
          &lt;?php
          }
      }
      ?&gt;
  
  &lt;?php   
      include ("footer.php");
  ?&gt;
  </code></pre>