multiple list values to one field
Moderator: General Moderators
-
kristie380
- Forum Commoner
- Posts: 36
- Joined: Sun Oct 09, 2005 10:51 pm
multiple list values to one field
Is there a way to save multiple list selections from a form field into 1 field in MySQL? Right now it's only saving the first entry from my list. Thanks!
-
timclaason
- Forum Commoner
- Posts: 77
- Joined: Tue Dec 16, 2003 9:06 am
- Location: WI
Do:
Then on the post page:
I think that will work
Code: Select all
<SELECT MULTIPLE NAME='choice[]'>
...
</SELECT>
Code: Select all
foreach($choice as $value) {
...
}-
kristie380
- Forum Commoner
- Posts: 36
- Joined: Sun Oct 09, 2005 10:51 pm
could you expand on the post page part? here is my code...
HTML:
PHP:
HTML:
Code: Select all
<select name='activities[]' size="10" multiple="multiple" id="activities">
....
</select>PHP:
Code: Select all
$date = date("Y-m-d G:i:s");
$sql = "INSERT INTO `signup2` VALUES (
\"\",
\"$_POST[firstname]\",
\"$_POST[lastname]\",
\"$_POST[maidenname]\",
\"$_POST[gradyear]\",
\"$_POST[email]\",
\"$_POST[city]\",
\"$_POST[state]\",
\"$_POST[country]\",
\"$_POST[url]\",
\"$_POST[email_private]\",
\"$_POST[aol]\",
\"$_POST[myspace]\",
\"$_POST[activities]\",
\"$_POST[update]\",
\"$_POST[username]\",
\"$_POST[password]\",
\"$date\",
\"$date\"
)";I fear that you're missing some fundamental concepts about databases and PHP. I know it's hard to get started and everyone always wants to have somebody "just tell me how to do this," but that's often not possible. Unless I don't understand your question, you should never try to do what you described, it violates the rules of relational database normalization.