deleting records with looped check boxes in PHP
<p>below is part of my code where I'm trying to delete database records via a checkbox pick. The loop is how I get the data along with the check box. (code 1:) and (code 2:) is where I'm trying to delete the selected records.</p>

<p>As you may see in the loop there are 3 fields in the database and when deleting the records the code 2 checks only the match with first record which is <code>bname</code>. However my issue is I need to check whether all three database fields are matched before deleting from the system.
To explain the issue further;</p>

<pre><code>bname | bvariant | bsku
-----------------------
apple |red       | 20g
apple |green     | 30g
</code></pre>

<p>The current code looks at the match with "apple" and deleted all two data rows. But if the use has picked row no 1 then I need the code to be adjusted to check the match with the database for all three fields, in which case only apple, red, 20g will be deleted. I have added <code>AND bvariant='$wec2' AND     bsku='$wec3'"</code> to code 2 but seems it doesn't work. Pls help.</p>

<p><strong>Code 1:</strong>    </p>

<pre><code>while ($reK = mysqli_fetch_array($runBrands))
{
$wec = $reK['bname']; $wec2 = $reK['bvariant']; $wec3 = $reK['bsku'];
    echo "&lt;tr class='brndTab'&gt;";
    echo "&lt;td class='brndTab'&gt;".$reK["bname"]."&lt;/td&gt;";
    echo "&lt;td class='brndTab'&gt;".$reK["bvariant"]."&lt;/td&gt;";
    echo "&lt;td class='brndTab1'&gt;".$reK["bsku"]."&lt;/td&gt;";
    echo "&lt;td class='brc'&gt;&lt;input type='checkbox' name='delz[]' value='$wec' &gt;&lt;/td&gt;";
    echo "&lt;/tr&gt;";
}
</code></pre>

<p><strong>Code 2:</strong></p>

<pre><code>if(isset($_POST['delz'])) 
{
foreach($_POST['delz'] as $we)
  {
$Mo = mysqli_query($db,"DELETE FROM brands WHERE bname ='$we' AND bvariant='$wec2' AND     bsku='$wec3'");
  }
}
</code></pre>
