Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2007
    Location
    Canada
    Posts
    49
    Thanks
    1
    Thanked 1 Time in 1 Post

    Multiple Selections with checkboxes

    I need to have a series of options that can be selected with checkboxes. I suspect that in the future I'm going to need to add/delete/modify the number of these checkboxes.

    Can you suggest a better method of handling this than adding a field in my DB to match each checkbox on the form? I mean, if I have to change the number of check boxes down the road, I will have to recode the form and add/delete fields from the DB structure. Is there a method for retrieving an array of the checkbox results for example?

    Thanks
    Of all the things I've lost in my life time, my mind is the one I miss the most!

  • #2
    Regular Coder GO ILLINI's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    634
    Thanks
    0
    Thanked 7 Times in 7 Posts
    you can make one field called checkboxes (or whatever) and fill it with
    Code:
    one|two|three|four
    Then in the php if you save the field in the $str var:
    PHP Code:
    $checkboxes explode('|'$str);
    echo(
    $checkboxes[0]); // 'one'
    echo($checkboxes[3]); // 'four' 

    Then when you get a new checkbox you can add it on the end of that.

    -Adam
    Why not thank me?

    http://adamsworld.name


  •  

    Posting Permissions

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