#1
  1. Full Access
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jun 2000
    Location
    London, UK
    Posts
    2,019
    Rep Power
    17
    I am writing some forum software, and for the administration part of it, I want to be able to delete articles (plural). Currently, I can only do this with radio buttons, and an SQL query like:

    delete from db where (id = $id);

    Now the new challenge is to be able to have checkboxes instead of radio buttons so lots of articles can be deleted at once. Any ideas on how this would be done?

    --------------------------------------------
    Alex
    (http://www.alex-greg.co.uk)
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    1
    Rep Power
    0
    What if you use something like
    <input type=checkbox name=ID[]>
    ??

    I don't know if it works, because I only made something like this in listboxes

    Good luck
  4. #3
  5. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    First make your check box as array variable like following:
    Article1 <input type="checkbox" name="id[]" value="1">
    Article2 <input type="checkbox" name="id[]" value="2">
    Article3 <input type="checkbox" name="id[]" value="3">

    In your script you can pass the selected values to Delete sql query like following:

    <?
    for($a=0;$a<count($id[]);$a++){
    //loop through the selected item and delete that from the database..
    mysql_query("delete from db where (id = $id[$a])");
    }
    ?>



    ------------------
    SR -
    webshiju.com
    www.jobxyz.com-IT Career Portal
    ezipindia.com--WebStudio


    "The fear of the LORD is the beginning of knowledge..."

Similar Threads

  1. deleting selected records using checkboxes
    By shyster2003 in forum PHP Development
    Replies: 13
    Last Post: January 15th, 2004, 03:01 AM
  2. Deleting multiple values
    By bohuslav in forum ASP Programming
    Replies: 1
    Last Post: December 30th, 2003, 05:06 AM
  3. Multiple checkboxes for accept terms form
    By Foxel in forum HTML Programming
    Replies: 5
    Last Post: October 8th, 2003, 05:42 PM
  4. Replies: 2
    Last Post: October 8th, 2003, 02:26 AM
  5. Multiple checkboxes with same name??
    By cjgraphix in forum PHP Development
    Replies: 11
    Last Post: October 4th, 2003, 05:33 PM

IMN logo majestic logo threadwatch logo seochat tools logo