SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard
    Join Date
    Apr 2004
    Location
    dublin
    Posts
    2,036
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Inserting Checkbox Values

    Hi all,

    I have a group of checkboxes as below.

    How do I ensure that only the checked values are inserted into the database?

    Code:
     <td><input type="checkbox" name="equities_close" id="equities_close" value="close" /></td>
     <td><input type="checkbox" name="equities_bid" id="equities_bid" value="bid" /></td>
     <td><input type="checkbox" name="equities_ask" id="equities_ask" value="ask" /></td>
     <td><input type="checkbox" name="equities_mean" id="equities_mean" value="mean" /></td>
     <td><input type="checkbox" name="equities_manual" id="equities_manual" value="manual" /></td>

  2. #2
    SitePoint Wizard silver trophy Jelena's Avatar
    Join Date
    Feb 2005
    Location
    Universum, 3rd Corner
    Posts
    3,001
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Unchecked won't exist in $_GET or $_POST
    -- Jelena --

  3. #3
    SitePoint Zealot trekmp's Avatar
    Join Date
    Dec 2005
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If they are in a form I would just make all the names the same and loop through them, then only the ticked ones would appear anyway.

    Of you'll just have to do an isset check on each name to make sure its been ticked

    PHP Code:
     if(isset($_POST['equities_close'])) {
    //add to database



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
  •