![]() |
Checkboxes -> Database
How would I go about doing this:
Insert checked checkboxes into database as a set (into text field), the only complication is the # of checkboxes is an unknown, as there is one for every 'player' in the player table (values are IDs). The names of the fields all are: positionXXX (where XXX = playeriD). Sorry if this is yet another easy question, my brain shuts off sometimes. :rolleyes: |
You should name your fields as an array ie position[].
Then you can just serialize the array into the database field. |
Okay, I set them as position[$id], what do you mean by serialize the array?
|
PHP Code:
|
Could someone elaborate on this a little for me. Do I create the array first? and do I name them $position[$id] or just position[$id] (if position[$id] how does it know what $position is?)
|
You name the field in your form 'position[]' (or 'position[$id]' if the Id is relevant).
After submit your would do a: PHP Code:
|
Thanks for all the help so far.
2 small problems (I hope): I have a select menu of all the players, I want to restrict the players by only showing results where FIND_IN_SET('$id', fieldname) but I need the $id to be the current $id that mysql is processing, the other problem is, if the id is 1, 11, 21, 108, and 3081, all of these will be included. Is there a way to force X # of digits? If this makes the first problem easier, the field containing the string of numbers (ex: 1,3,4,25,234234,3563) is in another table, which is selected prior to all of this. |
Sorry you lost me now.
|
All times are GMT. The time now is 10:06 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|