--- davidabroad <[EMAIL PROTECTED]> wrote: > To be clear: what I'm trying to do is to add the selected values from > the group of check boxes as an array. I could add a field in the table > for each check box, but that would seem to be overkill. If there's a > way to upload the values as an array I think that would be cleaner. > > David
You could use a serialize() function to prepare the array to be placed in a string of sufficient size and unserialize() when getting it back out again. The varchar datatype in MySQL is limited to 255 bytes but the text datatype holds up to 65,535 bytes. The storage structure takes up some extra space so you will want to give this some consideration. Discussion of and examples of serialize() and unserialize() may be found on the PHP web site: http://php.net/serialize http://php.net/unserialize I might be tempted to use another approach. Use a join() function to place the elements of the array (without keys) into a string and use some specific character such as the comma or pipe (|) as a separator. When getting the data back out you can use split(). However, since this uses a regular expression, when you represent the separation character if it is a pipe you will need to use "\|" to "escape" the special character with meaning in regex. http://php.net/join http://php.net/split There are similar functions such as explode and implode to replace split and join. There are also some datatypes in MySQL which could be used with special queries to store data very efficiently. However, disk space is seldom a problem these days so I would not advocate this method. When devising your form you can give name values to the checkboxes such as: <input type='checkbox' name='choice[]' value='something'> label If you have several checkboxes with the name='choice[]' then the values selected by the user will be placed in an array in the $_GET or $_POST superglobal variable for the PHP script which receives the form that is named in the action parameter of the form. The method parameter (method='get' or method='post") will determine which superglobal will contain the values. You will normally want to use post because the length is generally unlimited (ok about 8M on many default installs) where get is limited by the maximum length of a URL (2K on MSIE) and this can create some unpleasant surprises and some ugly URLs. You can experiment with no value defined in the checkbox to see what sort of values are passed along. If you want to have specific keys associated with each value you can do this in the square brackets and these will be used in the associative array in $_GET or $_POST. James Keeline
