Collecting choices from several selection boxes and storing them

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I am very new with php so excuse me please if the question seems really
easy.I have a page(form) which displays a list of the titles of some
books(retreived from a database) and each title has a selection box with
option values 1 to 7 each.The user should be able to enter 7 choices of his
favourite books and store them in the database at a table called preferences
with fields: customer_id ,first_choice, sec_choice,third_choice etc.I am
really stuck in implementing how I can collect the choices and link them
with each book's code so that i can store them in the table.I would really
apreciated if somebody could give me at least a hint.
Thank you

Re: Collecting choices from several selection boxes and storing them

*** nt9 escribió/wrote (Tue, 31 Aug 2004 18:59:40 +0100):
Quoted text here. Click to load it

PHP allows you to treat form fields as arrays if you give them the
appropiate name. I particularly love arrays. In your case it could be
something like:

<select name="book[1244][]" multiple>
<option value="foo">Foo blah blah</option>
<option value="bar">Bar bleh bleh</option>

where 1245 is the book ID in database. Then in your script you'll have as
may arrays as books, each one containing as many elements (arrays) as
selected options:

$_POST['1245'][0] --> 'foo'
$_POST['1245'][1] --> 'bar'

-+ Álvaro G. Vicario - Burgos, Spain - ICQ 46788716
+- (la web de humor para mayores de 100 años)
++ «Sonríe, que te vamos a hacer una foto para la esquela»

Site Timeline