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:

And here’s more info about the MySQL statements and stuff:

I learned a lot today, that’s for sure!

Posted on May 25th, 2007 | Leave a comment | Trackback URL

16 Comments

  1. Maryam

    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

  2. LearningNerd

    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. ;)

  3. MSQL, PHP & Tick Boxes | Stevp's Blog

    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 […]

  4. Carl

    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!

  5. sasi

    November 7th, 2008

    I have an one doubt checkbox used delete in row

  6. seetha

    November 7th, 2008

    is there an hints in php

  7. liz

    December 6th, 2008

    this video isn’t working.

  8. Insia

    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!

  9. LearningNerd

    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!

  10. Insia

    January 2nd, 2009

    dont worry abt it :)

  11. Silver

    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

  12. Paul Canning

    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 :D

    Thank you ever so much!

  13. Rana

    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,

  14. Victoria

    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!

  15. Lucy

    September 8th, 2009

    Thanks so much! I’m working on a project, and this time, I actually understand what I’m doing.

    Thanks again!

  16. El

    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!

Share Your Thoughts