
October 9th, 2012, 01:59 PM
|
 |
Confused badger
|
|
Join Date: Mar 2009
Location: West Yorkshire
|
|
Quote: | Originally Posted by stoyleg I have 10 list menus on a page. I want to take the values selected in each menu and insert them, one row at a time, into one mysql column.
I think an array is required, but I don't know how to get values from multiple list menus into and array and then insert these into a database.
Any help much appreciated. |
Name the menus the same name with [] at the end; for example:-
<select name='mymenu[]'>
<option value=1>1</option>
<option value=2>2</option>
...
<option value=5>5</option>
</select>
<select name='mymenu[]'>
<option value=A>B</option>
<option value=B>B</option>
...
<option value=E>E</option>
</select>
Then, when submitted, the data is already in an array called, in this case 'mymenu', you can either write that as a lump into MySQL or do a foreach / for loop, inserting one selection at a time.
__________________
The number for UK Emergencies is changing, the new number is 0118 999 881 999 119 7253
"For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
- George Orwell, 1984
|