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

Getting multiple selection into one string

P: n/a

I have a listbox with 5 options.
I have set it up to be able to choise more than one option.

What I need to know is how to get all the selection into the one string
that is stored in the DB

It is easy to get the first selected option to post into the DB.

Thanks for your thoughts and aideas.

Polar ;)
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Polar wrote:

I have a listbox with 5 options.
I have set it up to be able to choise more than one option.

What I need to know is how to get all the selection into the one string
that is stored in the DB

It is easy to get the first selected option to post into the DB.

Thanks for your thoughts and aideas.

Polar ;)

Hi Polar,

Use arrays.
Check the following code:

<html>
<body>
Received:
<br>
<?
// empty?
$mySelection = array();
if (isset($_POST["mySelection"])) {
$mySelection = $_POST["mySelection"];
}
foreach ($mySelection as $key => $value) {
echo $mySelection[$key]."<br>";
}
?>
<hr>
make a selection:
<hr>
<form action="" method="POST">
<select name="mySelection[]" multiple>
<option value="green">green
<option value="42">42
<option value="adams">adams
<option value="earth">earth
<option value="Zaphod">Zaphod
</select>
<input type="submit" value="send it">
</form>
</body>
</html>

Regards,
Erwin Moller
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.