473,244 Members | 1,320 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,244 software developers and data experts.

handle selects w multiple values in php 5

Hi folks,

does php 5 have a problem with html select lists which allow to choose
multiple items?

Whatever I tried I just can't get another or more than the last item
selected in the list.
Even if I select multiple items, a print_r($_POST) just shows the last
selected item, and not a array of all selected values.

Thanks very much for every hint,
yours Henri

--
| Henri Schomäcker - BYTECONCEPTS, VIRTUAL HOMES
| * * Datendesign für Internet und Intranet
| * * * * http://www.byteconcepts.de
| * * * * http://www.virtual-homes.de
Jul 17 '05 #1
3 2225
On Fri, 18 Feb 2005 20:27:01 +0100, Henri Schomaecker <hs@byteconcepts.de>
wrote:
does php 5 have a problem with html select lists which allow to choose
multiple items?

Whatever I tried I just can't get another or more than the last item
selected in the list.
Even if I select multiple items, a print_r($_POST) just shows the last
selected item, and not a array of all selected values.


It's not changed since PHP4 - the trick is to put [] after the name, e.g.

<select multiple='multiple' name='something[]'>

The [] causes PHP to form an array from the data; without it, the last value
overwrites the previous ones.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2

"Henri Schomaecker" <hs@byteconcepts.de> wrote in message
news:cv*************@news.t-online.com...
Hi folks,

does php 5 have a problem with html select lists which allow to choose
multiple items?

Whatever I tried I just can't get another or more than the last item
selected in the list.
Even if I select multiple items, a print_r($_POST) just shows the last
selected item, and not a array of all selected values.


Try using name="somevar[]" - certainly with checkboxes, this populates
multiple values into the array, should work with select lists too...

Matt
Jul 17 '05 #3
Henri Schomaecker wrote:
Whatever I tried I just can't get another or more than the last item
selected in the list.
Even if I select multiple items, a print_r($_POST) just shows the last
selected item, and not a array of all selected values.


Besides the recommendations of Andy and Matt, you can also enable the
always_populate_raw_post_data directive in your php.ini file.

After doing this, you can use your selects as before and will find the
posted data in the $HTTP_RAW_POST_DATA variable in the following format:

sel=A&sel=B&sel=C
JW

Jul 17 '05 #4

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

Similar topics

1
by: Marc | last post by:
Hello, I have a form with multiple selects (pullDown). All selects have the same name but each select has a different value. The user selects a value in each select. When he submits the form I...
8
by: Grant Edwards | last post by:
Perhaps I'm doing something wrong: the struct module docs say it's IEE 754, but I can't figure out how to get it to handle NaN values correctly (either packing or unpacking). >>> x =...
0
by: VIJAY KUMAR | last post by:
I have a problem with Refresh button when user add a new record. Sample Code: Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click...
7
by: Nick Calladine | last post by:
Hi On my form i have multiple select which all have an id value total1, total2, total3 etc so i am trying to detect how many there are and then use this to caculate a total. Is there a...
1
by: d.schulz81 | last post by:
Holas, I want to do the following: If one entry in multiple select "domain" is selected, i want to change the content in dropdown "typ" dynamically according to the selected domain. If more...
19
by: rich | last post by:
I am building an app using php and postgresql. My questionis this. How do you handle people wanting to make parallel changes to a record. Since in web apps you are doing a select, bring over a...
52
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible...
7
by: AboutJAV | last post by:
Hi, I was thinking of using MSMQ to handling multiple simultaneous database request to update or insert records to table. There could be hundreds of database existing connections trying to...
3
by: psycho | last post by:
I am working on an N-tier application using following components: 1. Data Access Layer using DLINQ which consists of Data Context class and Table Mapping classes. 2. Business Logic Layer....
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
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
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...

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.