Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9196889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:56:58+00:00 2026-06-17T21:56:58+00:00

Hi I’m a newbie to PHP and please help me understand where I’ve gone

  • 0

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.

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

If the information provided isn’t sufficient please highlight. Thank you.
Validation bit :

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'");
    } 
  }

Populating checkboxes for each data row extracted from the database:

while ($reK = mysqli_fetch_array($runBrands))
{
$wec = $reK['bname'];
    echo "<tr class='brndTab'>";
echo "<tr>" 
."<td><input type='submit' name='deleteR' id='deleteR' value='Delete.'></td>". 
"</tr>";    
echo "</table>";
    echo "<td class='brndTab'>".$reK["bname"]."</td>";
    echo "<td class='brndTab'>".$reK["bvariant"]."</td>";
    echo "<td class='brndTab1'>".$reK["bsku"]."</td>";
    echo "<td class='brndTa'><input type='checkbox' name='deletez[]' value='$wec'></td>";
    echo "</tr>";
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:56:59+00:00Added an answer on June 17, 2026 at 9:56 pm

    First you shouldn’t connect to the db inside the loop, move the line $db = mysqli_connect(‘localhost’, ‘root’, ”, ‘regional_data’); outside of the foreach loop. Otherwise you open a new connection for each entry. Next, you have an error in the mysql syntax, correct statement would be DELETE FROM brands WHERE bname =’$wec'”. Because you want to delete the row, not the contents of the row. To put this together, modify your code like this:

    $db = mysqli_connect('localhost', 'root', '', 'regional_data');
    if(mysqli_connect_errno()) {die('The connection to the database could not be established.');}
    foreach($_POST['deletez'] as $wec) {
        $rW = mysqli_query($db,"DELETE FROM brands WHERE bname ='$wec'");
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.