First PHP/MySQL Project Day 4: Checkboxes and Deleting Rows
Today I learned how to delete rows from a table in MySQL using an HTML form with dynamically generated checkboxes. (Whew, that was a mouthful!) To put it all together, I had to learn about a bunch of different things: how PHP handles checkboxes, primary keys, how to add a column to a table, a couple new MySQL statements, and a new PHP function. The video is eight and a half minutes long.
Links for Checkboxes and Deleting Rows
Here are the examples I copied from:
- PHP MySQL Create (And Primary Keys) - The last section explains primary keys and gives an example. (See Unique Key for more details on primary keys.)
- Add a Column to an Existing MySQL Table - A few examples of the
ALTERstatement. - Checkbox Deletion - I didn’t actually use this example, but I did learn from it.
- Comment by Stefan on the PHP Manual - This is the example I used instead of the previous one.
And here’s more info about the MySQL statements and stuff:
I learned a lot today, that’s for sure!



April 17th, 2008
Hello Dear Liz,
Thanks for useful issues,
I have encountered one problem in this example :While I deleted the rows “-tagged “won’t be deleted in none of them.
Is there any hint for that?
Thanks for your time and consideration.
Looking forward for more videos from you .
Best Regards,
Maryam
April 18th, 2008
Maryam - Glad you found it helpful! I remember being confused by that “-tagged” line… The solution is probably to just not let the HTML form submit empty inputs in the first place. You should first check if the text inputs actually contain text before inserting them into MySQL. (I should’ve learned how to do that! I will in the future.)
As for why the row won’t delete, I’m not sure why that is! I still have a lot to learn, obviously.
June 19th, 2008
[…] I’ve done loads of reading and searching and found pieces of the puzzle all over the net. This video however was most useful, although it isnt quite what i’m after it helped get my head round a […]
June 25th, 2008
Thanks for the tutorial, i’ve been spending days trying to get my form work but when I found your site it took just minutes.
Once again thank you for saving me time and for the great education!
November 7th, 2008
I have an one doubt checkbox used delete in row
November 7th, 2008
is there an hints in php
December 6th, 2008
this video isn’t working.
December 28th, 2008
Hi , could you post the full php files that you create here…it will help us compare and debug …extremely helpful site ,thank you so very much for putting it up ..keep up the good work!
December 30th, 2008
Insia - I would, but I did these tutorials a long time ago and I lost those files.
In the future I plan to post the files along with the tutorials, though. Thanks!
January 2nd, 2009
dont worry abt it
January 24th, 2009
thank you very very very much!!!
i tried to do this a hundred times and i was
never able to accomplish that, now i can hhh
February 9th, 2009
This little video was just the ticket in helping me figure out how to get multiple checkboxes to work!
I will surely be keeping hold of this piece of PHP coding and will make use of it in several projects
Thank you ever so much!
March 19th, 2009
Hello sir/madam i want to know how to generate check boxes like category example
main heading
subheading
check box 1
check box 2
check box 3
then user select more check boxes from different sub heading and at last send email to the selected items.
please explain me in detial
thanks,
July 10th, 2009
Thank you SO much!!! I found another script that worked except it kept giving me an undefined output error. I was so frustrated as I’ve been trying to get this script to work for days. After combining info from your script with what I already have my script now works flawlessly. Keep up the good work!
September 8th, 2009
Thanks so much! I’m working on a project, and this time, I actually understand what I’m doing.
Thanks again!
November 18th, 2009
Thanks for the very clear tutorial! I was really struggling with this concept, trying to wade through a bunch of irrelevant google search results and people giving confusing advice on forums. You really helped me understand!