SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Grabing checkbox values then insert into db

    I have a list of checkboxes that users can check or not. If out of 10 checkboxes, User only selects 5. It will take those 5 and put it in a DB

    i know how to put in DB..but how can i take all values of checkbox in a variable..do i put in array?

    any example of code would help

  2. #2
    Internet Business Optimizer KCgame's Avatar
    Join Date
    Mar 2005
    Location
    Singapore
    Posts
    935
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Assume you have the following form:
    PHP Code:
    //form action here
    //..
    <input name="option1" type="checkbox" value="1">
    <
    input name="option2" type="checkbox" value="1">
    /*other checkboxes with other values and names */ 
    You can check the values by using $_POST:
    PHP Code:
    $_POST[option1// this will contain the checkbox value. If its ticked in this case, it should be 1 
    Use the respective $_POST variables to input into your db.

    Hope it helps


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
  •