PHP function problem
<p>I have a php function script that is supposed to uncheck a checkbox or checkboxes if a user unchecks it when the preview button is clicked but I can only get the last 
checkbox that was unchecked to stay unchecked but not the other checkeboxes how can I fix this so that all the checkboxes that where unchecked stay unchecked?</p>

<p>Here is part of my PHP function that is giving me the problem.</p>

<pre><code>if(isset($_POST['preview'])){
    foreach($query_cat_id as $qci) {
        if(!in_array($qci, $cat_id)){
            $unchecked = $purifier-&gt;purify(strip_tags($qci));
        }
    }
}


for ($x = 0; $x &lt; count($query_cat_id); $x++){
    if(($query_cat_id[$x] == $cat['id']) &amp;&amp; ($cat['id'] != $delete_id) &amp;&amp; ($cat['id'] != $unchecked)){
        echo 'checked="checked"';
    }
}
</code></pre>
