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