473,320 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Collecting choices from several selection boxes and storing them

nt9
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
Jul 17 '05 #1
1 1406
*** nt9 escribió/wrote (Tue, 31 Aug 2004 18:59:40 +0100):
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.


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>
....
</select>

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
+- 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»
--
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John Ryan | last post by:
I've a small bit of javascript on my site that has a from with 2 selection boxes, when you choose an option in the first box, the second one re-populates its list accordingly. But the second...
198
by: Sy Borg | last post by:
Hello: We are designing two multi-user client server applications that performs large number of transactions on database servers. On an average Application A has a 50% mix of select and...
9
by: Frances | last post by:
Hi All, * PREMISE * I'm creating an Access form with 150 items subdivided into 20 categories. Multiple categories (and items) can be selected so my user wants checkboxes. All of the options...
9
by: Mark Lancaster | last post by:
I have several combo boxes on form1 of my application. I do not know why, but the choices on my dropdownlist combo boxes no longer display when the form opens. They are there, because you can...
9
by: Rhino | last post by:
How hard (and desireable) would it be to give the user certain choices when it comes to printing web pages? The pages on my site use colours and pictures and contain an imbedded menu, among...
5
by: njb35 | last post by:
Hi all I'm beginning my foray from VBA into VB 2005 Express, and enjoying some of the efficiencies it provides! I'm stuck with some dataset handling however that I _think_ can be automated but...
4
by: wideasleep | last post by:
Hello everyone, I am looking for a way to remove choices from cascading combo boxes as each selection is made. Here's how this is laid out. The initial combo box is STAGE and it will have...
6
by: Dave | last post by:
I want to put the information that the user selects in my combo boxes into a subform that lies on the same form as the combo boxes. Thanks for your help already, Dave
4
by: sialater | last post by:
Hello, I realise there are a lot of topics related to this problem but many of what I have found has run cold or unresolved. What I have is an addressbook clone where there are groups which have...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.