08-30-2010, 08:44 PM
|
#2 (permalink)
|
|
The Addict
Join Date: Aug 2008
Posts: 336
Thanks: 8
|
So you want to stored an array of selected colors in 1 field.
I would say store the array as a string in the field. Something like this:
php Code:
<?php//to store it coming from the post info of the submitted form.//$color var is the array from the choices, preferably sanitized. $colors = join(';', $color); $db = new mysqli ('localhost', 'user', 'password', 'app_db'); if (mysqli_connect_errno ()) { trigger_error("Can't connect to MySQL Server. Errorcode: %s\n", mysqli_connect_error ()); } if($db-> query("INSERT INTO users (name,lastname,color,date,desc) VALUES ($name, $last, $colors, NOW(), $description)")) { echo "The user was inserted!"; } else { trigger_error("There was an error trying to save user $name"); }$link-> close(); ?>
Then when you want to show the list, just query the db and split by the ';' string and you would get back the array of colors.
|
|
|
|