Help implementing checkboxes with submission to database. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Help implementing checkboxes with submission to database. (/showthread.php?tid=36159) |
Help implementing checkboxes with submission to database. - El Forum - 11-23-2010 [eluser]rreynier[/eluser] I am trying figure out the best way to have form data be submitted to a database. Currently I have a table with a column for each form input. The only problem I have found is with check boxes since you can have multiple items being checked. There is just one field (column) for a section of check boxes. So lets say there is an area for "choose your methods of contact" with 3 possible checkboxes: mail, phone call, snail mail. How would I go about entering this into the database without creating 3 separate fields in the database table which have an on and off state? Any pointers would be appreciated, thanks! Help implementing checkboxes with submission to database. - El Forum - 11-23-2010 [eluser]pickupman[/eluser] You want to [url="http://us2.php.net/manual/en/function.serialize.php"]serialize()[/url] the array to create a delimited string. You can then unserialize() back out of DB into an array. That's even how CI stores session information in DB when enabled. |