By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,614 Members | 1,674 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,614 IT Pros & Developers. It's quick & easy.

inserting values from a multiple selection list menu using dreamweaver php

P: 1
hello am a relative newbie to php. am using dreamweaver,php/mysql. i want to populate a mysql field using a multiple selection list menu. i have been to countless forums and so far nothing. can somebody please please help me. i want to insert the multiple selections into one column. i will really appreciate any response
Feb 23 '07 #1
Share this Question
Share on Google+
2 Replies


Motoma
Expert 2.5K+
P: 3,235
hello am a relative newbie to php. am using dreamweaver,php/mysql. i want to populate a mysql field using a multiple selection list menu. i have been to countless forums and so far nothing. can somebody please please help me. i want to insert the multiple selections into one column. i will really appreciate any response
Welcome to theScripts.

It sounds to me like what you are trying to do is have one entry in MySQL have multiple entries of an HTML element.
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO htmlTable (htmlCode) VALUES ("<select><option>option1</option><option>option2</option></select>")
  2.  
Let me be the first to say, this is not how databases are designed to be used: it is an nearly useless, and quite ineffective way of dealing with data.

If this is not what you are trying to accomplish, and I have misunderstood you, please post back describing your situation a little more thorougly.
Feb 23 '07 #2

ronverdonk
Expert 2.5K+
P: 4,258
Assuming the (multiple) select box name is 'list[]', you can use the implode() function to create a string of values from the POSTed 'list' array, separated by a value, in this sample a comma. You can now insert $string in your MySQL table column.

[php]
if (isset($_POST['list'])) {
$string = implode(",", $_POST['list']);
echo $string; // $string contains all values sep.by a comma
exit;
}[/php]

Ronald :cool:
Feb 23 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.