deleting "checked" records via populated checkboxes in PHP
<p>Hi I'm a newbie to PHP and please help me understand where I've gone wrong. Below is an extraction of the lengthy code I have where I'm trying to get SQL database values to a table with checkboxes adding in-front, allowing users to pick and delete the record they want. My issue is once a record is picked through the checkbox and hit delete, the record isn't getting deleted.</p>

<p>The <code>Validation bit</code> is what I have in the code to delete the checkbox picked values. <code>Populating checkboxes for each data row extracted from the database:</code> will tell you how I'm getting the checkboxes via the loop. </p>

<p>If the information provided isn't sufficient please highlight. Thank you.
<strong>Validation bit :</strong></p>

<pre><code>if(isset($_POST['deletez'])) 
  {
    foreach($_POST['deletez'] as $wec)
    {
    $db = mysqli_connect('localhost', 'root', '', 'regional_data');
    if(mysqli_connect_errno()) {die('The connection to the database could not be established.');}
    $rW = mysqli_query($db,"DELETE * FROM brands WHERE bname ='$wec'");
    } 
  }
</code></pre>

<p><strong>Populating checkboxes for each data row extracted from the database:</strong></p>

<pre><code>while ($reK = mysqli_fetch_array($runBrands))
{
$wec = $reK['bname'];
    echo "&lt;tr class='brndTab'&gt;";
echo "&lt;tr&gt;" 
."&lt;td&gt;&lt;input type='submit' name='deleteR' id='deleteR' value='Delete.'&gt;&lt;/td&gt;". 
"&lt;/tr&gt;";    
echo "&lt;/table&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='brndTa'&gt;&lt;input type='checkbox' name='deletez[]' value='$wec'&gt;&lt;/td&gt;";
    echo "&lt;/tr&gt;";
}
</code></pre>
