hi to all
i need small help in php.
how to store multi select box values in database.suppose one person prefers 2 or 3 cities in a country.during the normal process last selected value is stored in database.but i want to store all selected values in multiple select box.
thanks in advance..
multi select box
Moderator: General Moderators
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Perhaps you should start by writing in complete sentences, you know, with things like capitalization. Maybe you could throw in a couple spaces after periods for fun.
Better yet, maybe you should write a filter in PHP that will do this. You can type in your post into a form field, then it will convert your text to something more readable and then you can copy and paste it. This would be very good regular expression practice.
As for your question you can pass html form elements as arrays by naming the element with brackets like the following
Then in php
Better yet, maybe you should write a filter in PHP that will do this. You can type in your post into a form field, then it will convert your text to something more readable and then you can copy and paste it. This would be very good regular expression practice.
As for your question you can pass html form elements as arrays by naming the element with brackets like the following
Code: Select all
<select name="stuff[]" multiple>
<option value='1'>stuff</option>
<option value='2'>more stuff</option>
<option value='3'>turkey</option>
</select>
Code: Select all
// This is now an array
$stuff = $POST['stuff'] ;
foreach( $stuff as $value )
{
echo $value ; // Prints out the selected values
}