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

Retrieve HTML array created from a list box

105 100+
Hey folks, I was expecting an array to be returned with the following code for a multi-select dropdown list but I get single values. Can anyone help?


Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3.     if(isset($_POST['submit'])){
  4.  
  5.         print_r($_POST);    
  6.  
  7.     }
  8.  
  9. ?>
  10.  
  11.  
  12. <form method='post' >
  13.  
  14.     <select name="time" size=3 multiple>
  15.         <option value="Morning">Morning</option>
  16.         <option value="Day">Day</option>
  17.         <option value="Night">Night</option>
  18.     </select>
  19.  
  20.     <input type="submit" name='submit' value="submit" />
  21.  
  22. </form>
  23.  
  24.  
Jan 17 '10 #1

✓ answered by Atli

Hey.

If you want PHP to receive an array from a form, the <input> element(s) must end with [] brackets - in much the same manner you would use them with PHP variables.

In your case:
Expand|Select|Wrap|Line Numbers
  1. <select name="time[]" size=3 multiple>

2 1916
Atli
5,058 Expert 4TB
Hey.

If you want PHP to receive an array from a form, the <input> element(s) must end with [] brackets - in much the same manner you would use them with PHP variables.

In your case:
Expand|Select|Wrap|Line Numbers
  1. <select name="time[]" size=3 multiple>
Jan 18 '10 #2
aktar
105 100+
Aha! thank you very much. Great help
Jan 18 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jefferis NoSpamme | last post by:
Hi folks, Trying to fill in a gap in my understanding of php, and so this is rather newbish: I have created a form where a user selects 2 items from a list of 8 values. That form field is...
5
by: David Rasmussen | last post by:
Some sites seem to be session driven in the sense that if I visit the homepage and do a few clicks I can navigate anywhere I want, but if I paste the current location into a new browser window...
2
by: forums_mp | last post by:
I've got an STL class (see below) with two functions to store and retrieve data - msg structs. The "Store" function when called will copy the received message (depending on which message) into...
0
by: Brian Henry | last post by:
Since no one else knew how to do this I sat here all morning experimenting with this and this is what I came up with... Its an example of how to get a list of items back from a virtual mode list...
14
by: Peter Hallett | last post by:
I would like to set up a string array as a class member, or field, and then populate this array by reading in from a text file, but I cannot find the appropriate syntax. The getter and setter are...
19
Atli
by: Atli | last post by:
Introduction At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect...
5
by: dwmartin18 | last post by:
Hello everyone. I have quite the puzzling problem with a script I have been working on lately. I have created a function that can be called to create a new html element (e.g. input, select, div,...
2
by: StevenChiasson | last post by:
For the record, not a student, just someone attempting to learn C++. Anyway, the problem I'm having right now is the member function detAddress, of object controller. This is more or less, your...
35
by: Lee Crabtree | last post by:
This seems inconsistent and more than a little bizarre. Array.Clear sets all elements of the array to their default values (0, null, whatever), whereas List<>.Clear removes all items from the...
9
by: gavy7210 | last post by:
hello friends i am new to struts. i want to add the user information in the database and then display it back to him. i am using struts 1.2,Eclipse Platform Version: 3.4.2,mySql 5.0.1,jdk...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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,...
0
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...

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.