Click here to Skip to main content
16,018,805 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to insert selected listbox values into a dababase using php
Posted
Comments
Marc A. Brown 24-Mar-11 9:56am    
What have you tried? What problems have you encountered?
Sandeep Mewara 24-Mar-11 9:58am    
Good to know. Now, what have you tried and where are you stuck?

1 solution

Ruthi,

This process is quite simple.. If you have a list box as so:

XML
<select name="list[]" id="Select1" size="4" multiple="multiple">
    <option value="1">item 1</option>
    <option value="2">item 2</option>
    <option value="3">item 3</option>
    <option value="4">item 4</option>
</select>


The name of the list box is list[] specified as an array. When you submit this form you can iterate through the list array and store the data into the database such as:

foreach($_REQUEST['list'] as $list) {
//Store $list items in the database.
}

Hope that helps?

Thanks

Russell
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900