3 Replies Latest reply on Feb 8, 2011 4:42 PM by bregent

    Multiple check boxes in an update form

    WayneRowlands

      I have a database of the membership of a club. One field in the database is input by checking multiple check boxes. When the insert member record is submitted and multiple check boxes are selected, the information becomes an array of text separated by commas. When the user goes back to the update form, the check boxes are not showing checked in the appropriate fields. Please go to my test site where you will be able to see the code that I have created so far: http://www.usreboot.com/phphelp.php. You will need a user name and password to look at the update record page. Here you go: user name: wyane, password: wayne. I have submitted this request in the past and have not found success so far. Thanks for your help, Wayne Rowlands

        • 1. Re: Multiple check boxes in an update form
          bregent Most Valuable Participant

          >One field in the database is input by checking multiple check  boxes.

          >When the insert member record is submitted and multiple check  boxes

          >are selected, the information becomes an array of text separated  by commas.

           

          This is poor database design. Although it's possible to use php and MySQL functions to deal with this, it is still a bad way to store data. Why not just use a seperate database field for each option - or - create another table to store the option values?

          • 2. Re: Multiple check boxes in an update form
            WayneRowlands Level 1

            Thanks for getting back with me. I do have two tables. One table is the "members" table where all the information for the members is stored. One of the columns is "currentClubPositions". The database has another table which is "positions" which has the list for the positions that a member of the club could serve on. Members of the club may be serving on a number of positions at once, therefore the check boxes. Also, the club is adding and deleting positions over time, so I wanted an easy way to add them and delete them without having to go into phpmyadmin to do this. I have created a form that updates the "positions" table. The check boxes that show up in the insert member record and update member record are dynamic so that when the table "positions" changes, the forms change dynamically as do the queries to sort the database change dynamicaly. When the check boxes are entered, I use the implode function to make the values an array of text separated by commas and that value is inserted in one field of the members table named "currentClubPosition". I am all ears to hear a better way. Take a look at the web pages (see the original post) that I have created and you will see how all this ties together. Thanks, Wayne Rowlands

            • 3. Re: Multiple check boxes in an update form
              bregent Most Valuable Participant

              A better database design would be to insert a row in the position table for each position assigned to a member. So if 'Joe' holds 5 positions, he would have 5 rows in the table.

               

              Of course it's possible to do what you want with your existing design, but I don't do PHP so I can't really help much with the code. You're also better off asking these questions in the app dev forum, and be prepared to provide the php code for the form pages.

              1 person found this helpful