SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Wizard bronze trophy cydewaze's Avatar
    Join Date
    Jan 2006
    Location
    Merry Land, USA
    Posts
    1,096
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Deleting from database using checkbox values

    This seems like such a no-brainer, and I'm sure I'm missing something very simple!

    I have a form that has rows queried from a database, and each row has a checkbox with the value equal to the ID number for that row. I want to be able to check each row I want to delete, hit submit, then have them gone. So I've done this:

    <input type="checkbox" name="deleterow" value="#comment_id#">

    DELETE FROM comments
    WHERE comment_id IN ( <cfqueryparam value="#FORM.comment_id#" list="yes">)

    But it only deletes the first instance passed. Do I need to make a loop or something? Why won't they delete all at once? I've dumped the form variables and the checkbox value is a comma-delimited list of the expected numbers.
    <cfset myblog = "http://cydewaze.org/">

  2. #2
    SitePoint Wizard bronze trophy cydewaze's Avatar
    Join Date
    Jan 2006
    Location
    Merry Land, USA
    Posts
    1,096
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    I somehow managed to figure it out, and the problem was too many loops in the form.

    I was getting double values on some of the checkboxes, so I had something like 16 17 18, 17 18, 18. Needless to say, only that last one matched anything. I pulled a loop out and she works!
    <cfset myblog = "http://cydewaze.org/">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •