473,698 Members | 2,177 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2248
On Fri, 18 Feb 2005 20:27:01 +0100, Henri Schomaecker <hs@byteconcept s.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='multi ple' 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.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2

"Henri Schomaecker" <hs@byteconcept s.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
2445
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 want to put te values of the selects in a database so that the value of each select is added to a table and the option te user selected in that select in another table. e.g.
8
3557
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 = float('nan') >>> struct.pack("<f",x) Traceback (most recent call last): File "<stdin>", line 1, in ? SystemError: frexp() result out of range
0
1817
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 lblMesaage.Text = "First Name : " + txtFName.Text + " ,Lat Name : " + txtLName.Text txtFName.Text = Nothing txtLName.Text = Nothing
7
2120
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 javascript reference to basically go to a form and produce a loop which will show me how many select drop down boxes there on a form. Or would i have t use something like
1
1831
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 than one entries in domain are selected, i want the dropdown typ to disappear
19
1708
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 record then updating it, there is no lock on that record while you are making the changes in your browser window. Does transactions handle that? Do you make your selection and update all part of the same transaction? This whole scenario has me...
52
6324
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 variations(combination of fields), - then act on each group in some way ...eg ProcessRs (oRs as RecordSet)... the following query will get me the distinct groups
7
5242
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 access the same table. I was thinking to writing an app with threads to listen and 1 at a time handle each request on the queue. Is this a good approach? If not, is there a better way with .NET/C#?
3
7088
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. 3. Presentation Layer (normal ASP.NET pages) The problem is that I have to handle database transactions which can span multiple tables. So where should I place the transaction code. I think I should do it in BLL. But how do I control the transaction at...
0
9156
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7712
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4361
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4614
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2323
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1998
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.