Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
August 31, 2004, 11:59 pm
rate this thread
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.
- Alvaro G. Vicario
September 1, 2004, 4:00 am
Re: Collecting choices from several selection boxes and storing them
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
<select name="book" 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
$_POST['1245'] --> 'foo'
$_POST['1245'] --> 'bar'
-+ Álvaro G. Vicario - Burgos, Spain - ICQ 46788716
+- http://www.demogracia.com (la web de humor para mayores de 100 años)
++ «Sonríe, que te vamos a hacer una foto para la esquela»