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

getting multiple data from <select>

Can anyone give me a quick hint for this?

Say, I have: <SELECT NAME="opt3" SIZE="15" multiple>

Then I'd like to list the items selected...
echo $_POST["opt3"];
but this gives only the first one

how do I get the rest?

Feb 6 '07 #1
5 2460
"Sonnich" <so************@elektrobit.comkirjoitti
viestissä:11*********************@s48g2000cws.goog legroups.com...
Can anyone give me a quick hint for this?
Say, I have: <SELECT NAME="opt3" SIZE="15" multiple>
Then I'd like to list the items selected...
echo $_POST["opt3"];
but this gives only the first one
how do I get the rest?

<SELECT NAME="opt3()" SIZE="15" multiple>

Parenthesis is the point: NAME="opt3()"

Then php knows than an array is coming. This is not because html would
require that, but because php does. This applies not only to select
elements, but checkboxes as well for example. Or sometimes you may want to
send some array in hidden fields.

Feb 6 '07 #2
On Feb 6, 4:36 pm, "P Pulkkinen"
<perttu.POISTATAMA.pulkki...@POISTATAMA.elisanet.f iwrote:
"Sonnich" <sonnich.jen...@elektrobit.comkirjoitti
viestissä:1170772126.596200.67...@s48g2000cws.goog legroups.com...
Can anyone give me a quick hint for this?
Say, I have: <SELECT NAME="opt3" SIZE="15" multiple>
Then I'd like to list the items selected...
echo $_POST["opt3"];
but this gives only the first one
how do I get the rest?

<SELECT NAME="opt3()" SIZE="15" multiple>

Parenthesis is the point: NAME="opt3()"

Then php knows than an array is coming. This is not because html would
require that, but because php does. This applies not only to select
elements, but checkboxes as well for example. Or sometimes you may want to
send some array in hidden fields.
eeehhh I tried to play a bit around with this, but do I also need a
trick to read it out?

BR
Sonnich

Feb 6 '07 #3

"Sonnich" <so************@elektrobit.comwrote

"eeehhh I tried to play a bit around with this, but do I also need a
trick to read it out?"

Well, you need to loop through the array:

foreach ($opt3 as $key =$val)
{
echo "<p>".htmlspecialchars($key)."=".htmlspecialchars( $val)."</p>n";
}

That's something for ONE-dimensional array, though. Remember, no parenthesis anymore.
Feb 6 '07 #4
Rik
Sonnich <so************@elektrobit.comwrote:
On Feb 6, 4:36 pm, "P Pulkkinen"
<perttu.POISTATAMA.pulkki...@POISTATAMA.elisanet.f iwrote:
>"Sonnich" <sonnich.jen...@elektrobit.comkirjoitti
viestissä:1170772126.596200.67...@s48g2000cws.goo glegroups.com...
Can anyone give me a quick hint for this?
Say, I have: <SELECT NAME="opt3" SIZE="15" multiple>
Then I'd like to list the items selected...
echo $_POST["opt3"];
but this gives only the first one
how do I get the rest?

<SELECT NAME="opt3()" SIZE="15" multiple>

Parenthesis is the point: NAME="opt3()"

Then php knows than an array is coming. This is not because html would
require that, but because php does. This applies not only to select
elements, but checkboxes as well for example. Or sometimes you may want
to
send some array in hidden fields.

eeehhh I tried to play a bit around with this, but do I also need a
trick to read it out?

Well, don't use () in the name, but []...

A little hint for debugging POSTs: echo file_get_contents('php://input')
will give you the raw input.

Example:
------------------
POST:
<?php
var_dump($_POST);
?>
INPUT:
<?php
echo file_get_contents('php://input');
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<select name="check()" multiple>
<option>option 1</option>
<option>option 2</option>
<option>option 3</option>
<option>option 4</option>
<option>option 5</option>
<option>option 6</option>
</select>
<select name="check2[]" multiple>
<option>option q</option>
<option>option e</option>
<option>option r</option>
<option>option t</option>
<option>option y</option>
<option>option u</option>
</select>
<input type="submit">
</form>
------------------
--
Rik Wasmus
Feb 6 '07 #5

"Rik" <lu************@hotmail.comwrote
Well, don't use () in the name, but []...
Oops, thanks for correction.
Feb 6 '07 #6

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

Similar topics

2
by: Andrea | last post by:
Hi, I'm trying to emulate part of our client-server application as a web site so customers can use it, and I'm stuck when it comes to re-ordering items in a list. Basically we have a list of...
1
by: Burton Figg | last post by:
I have a SELECT statement which holds a list of times (for adding appointments to a database): e.g. <select name="time" id="time" size="3" multiple> <option value="00:00">00:00</option>...
1
by: Ang Talunin | last post by:
Hey, I wondering if it's possible to retrieve all the <option>-fields from a <select> when posting a <form> to a php file Example: I've got a form like this: <form action = phpfile.php...
7
by: Felix Natter | last post by:
hi, I have a php-Script which gets passed a Boat-ID and this is used to mark an element in a <select> as the default: <select name="boote" multiple="multiple" size="5"> <option...
6
by: Bonge Boo! | last post by:
This has got to be obvious, but I can't make it work. I have a form called with 3 pull down menus. They are linked to a database which generates the values for the <SELECT? Pull-downs. Lets...
4
by: joiv | last post by:
I'm making a <select></select> with lots of <option></option>. It contains all possible options. Because of the length of the list, I also have an <input type="text">. This is what I wish to do:...
5
by: Brian Foley | last post by:
Hello, I am used to using the label tag with check boxes and radio buttons in html forms. This allows me to click on the text of the label to activate/deactivate the check box / button, rather...
4
by: luftikus143 | last post by:
Hi there, I have a nasty little problem, as so often, only with IE. Here is an screenshot to better illustrate the problem. http://geodata.grid.unep.ch/screenshot13.png The map is clickable (to...
4
by: Man-wai Chang | last post by:
-- iTech Consulting Co., Ltd. Expert of ePOS solutions Website: http://www.itech.com.hk (IE only) Tel: (852)2325 3883 Fax: (852)2325 8288
1
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...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.