At 08:51, 19990831, Rod wrote:
>On a form I have several catagories in which one catagory may have up to 50
>checkboxes. Would someone kindly suggest the most efficient way to save the
>values to a table. I can store the values as an array into a variable with
>PHP but is it possible to then store this array into one field in a table?
>And if so, how do I extract the array values from the field.
Rod, you can use a SET type. Read all about it in the manual.
Another option is to have two extra tables, like this:
CREATE TABLE categories (id TINYINT UNSIGNED NOT NULL PRIMARY KEY,
name CHAR(15));
CREATE TABLE assigned_categories (thing_id INT UNSIGNED NOT NULL,
category_id TINYINT UNSIGNED NOT NULL
PRIMARY KEY (thing_id, category_id));
Now for each thing in your things table you can have any number of
categories selected. This is basically the same thing as using a SET
value, except it's the normal(ized) way to do it.
Tim

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.