title: Deleting Database Entries Not in Array
body: <p>I have an array that grabs checkbox data and posts certain information into the database if the checkbox data isn't a copy of something already in the database.  What I would like to know is how can I create a code that scans through the database and finds data that wasn't part of my checkbox data and delete it from the database.</p>
  
  <p>Okay, for example let's say I have values 1,2,3,4 in my database, but in my checkboxes I only get back 1,2,4.  I would like a code that scans my database and deletes that value(s) (in this case 3) from the database.</p>
  
  <p>Here is my current code:</p>
  
  <pre><code>foreach($_POST['publish'] as $index =&gt; $val){
  $matches = mysql_query("SELECT * FROM `$blog_table` WHERE `postID` = '$val");
      if (mysql_num_rows($matches) &gt; 0)
      {
          // do nothing
      } else {
      $query3 = "insert into `$blog_table`
                       (`postID`)values 
                       ('$val')";
      mysql_query($query3);   
      }
  }
  </code></pre>