473,386 Members | 1,785 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,386 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 2233
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....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.