473,396 Members | 2,052 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,396 software developers and data experts.

SELECT MULTIPLE only one in $_post

foreach($_POST as $element=>$val)
{
echo $element.'--'.$val.'<BR>';
}

Where a select multiple html field had several selected values only shows
one?? How do I get the others. php 5.1b

Thanks
Oak
Aug 7 '05 #1
4 4397

Oak Hall wrote:
foreach($_POST as $element=>$val)
{
echo $element.'--'.$val.'<BR>';
}

Where a select multiple html field had several selected values only shows
one?? How do I get the others. php 5.1b


How is your form defined?

Ken

Aug 7 '05 #2
Out take from the form, I get all the variables fine from the form, but the
Multiple gives only one of the selected ones. Also
print_r($_POST["Locations"]); shows only one value. Taking the same form
pointing it to another server language (paradox) works fine. Thanks Oak
<FORM name="searcher"
ACTION="/php/ide/data/frontend.php?lib=mls&cmd=PropertySearchPost"
METHOD="POST" >
<input type="text" size="4" name="MinAcres" value="">
<input type="text" size="4" name="MaxAcres" value=""><BR>
<SELECT MULTIPLE NAME="Locations" SIZE="10">
<OPTION SELECTED VALUE="All">All AREAS
<OPTION VALUE=",2459">Braxton
<OPTION VALUE="2459">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;flatwoods
(1)
<OPTION VALUE=",2259,2205,2206,2207">Fayette
</SELECT>
SUBMIT BUTTON
</FORM>
"Ken Robinson" <ke******@rbnsn.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...

Oak Hall wrote:
foreach($_POST as $element=>$val)
{
echo $element.'--'.$val.'<BR>';
}

Where a select multiple html field had several selected values only shows
one?? How do I get the others. php 5.1b


How is your form defined?

Ken

Aug 7 '05 #3

Oak Hall wrote:
Out take from the form, I get all the variables fine from the form, but the
Multiple gives only one of the selected ones. Also
print_r($_POST["Locations"]); shows only one value. Taking the same form
pointing it to another server language (paradox) works fine. Thanks Oak
<FORM name="searcher"
ACTION="/php/ide/data/frontend.php?lib=mls&cmd=PropertySearchPost"
METHOD="POST" >
<input type="text" size="4" name="MinAcres" value="">
<input type="text" size="4" name="MaxAcres" value=""><BR>
<SELECT MULTIPLE NAME="Locations" SIZE="10">
Make the name an array:
<select multiply name="Locations[]" size="10">
<OPTION SELECTED VALUE="All">All AREAS
<OPTION VALUE=",2459">Braxton
<OPTION VALUE="2459">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;flatwoods
(1)
<OPTION VALUE=",2259,2205,2206,2207">Fayette
</SELECT>
SUBMIT BUTTON
</FORM>


Then you're 'foreach' can be written:

foreach ($_POST as $k=>$v) {
echo $k
if (is_array($k))
foreach ($k as $k1=>$v1)
echo '<br>[' . $k1 . ']' . ' = ' . $v1;
else echo ' = ' . $v;
echo '<br>';
}

Note: code untested.

Ken

Aug 7 '05 #4
THANKS!

"Ken Robinson" <ke******@rbnsn.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...

Oak Hall wrote:
Out take from the form, I get all the variables fine from the form, but
the
Multiple gives only one of the selected ones. Also
print_r($_POST["Locations"]); shows only one value. Taking the same form
pointing it to another server language (paradox) works fine. Thanks Oak
<FORM name="searcher"
ACTION="/php/ide/data/frontend.php?lib=mls&cmd=PropertySearchPost"
METHOD="POST" >
<input type="text" size="4" name="MinAcres" value="">
<input type="text" size="4" name="MaxAcres" value=""><BR>
<SELECT MULTIPLE NAME="Locations" SIZE="10">


Make the name an array:
<select multiply name="Locations[]" size="10">
<OPTION SELECTED VALUE="All">All AREAS
<OPTION VALUE=",2459">Braxton
<OPTION VALUE="2459">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;flatwoods
(1)
<OPTION VALUE=",2259,2205,2206,2207">Fayette
</SELECT>
SUBMIT BUTTON
</FORM>


Then you're 'foreach' can be written:

foreach ($_POST as $k=>$v) {
echo $k
if (is_array($k))
foreach ($k as $k1=>$v1)
echo '<br>[' . $k1 . ']' . ' = ' . $v1;
else echo ' = ' . $v;
echo '<br>';
}

Note: code untested.

Ken

Aug 7 '05 #5

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

Similar topics

1
by: Greg Bryant | last post by:
Hi folks. I'm porting a cf site to php, everything's going very well, I like php much better (this, of course, being the correct forum to make that statement :). One problem I have is with...
3
by: imrantbd | last post by:
I need array type name like "destList" must use for my destlist select box,not a single name.Or need a solution to capture multiple value of "destList" select box and send all selected value in php...
1
by: Mitesh | last post by:
Hi, I have the following HTML code right now. Code: ------------------------------------------------------------------------------------------------------------------------- <td...
5
by: Sonnich | last post by:
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; but this gives only the first one ...
0
by: sundsx | last post by:
Hi, i would sen multiple select to mysql by form, my prb is: file connect.php <?php $user="sundsx"; $pass="password"; $db="testphp"; $val_form=$_POST; $service =$_POST;
3
by: shara | last post by:
Hello there, I want to pass multiple values selected in a select box(HTML) to another php page.I tried doing in several ways but of no use.Can anybody please help me with this. The code i used...
3
by: bcanter | last post by:
I am setting up a user request form to help our IT staff get all of the information required to setup a user account, I would like to send the form to a static address each time that it is submitted...
2
by: phpnewbie26 | last post by:
I currently have two drop down menus where the second one is populated from the first one. My second drop down menu should be able to do multiple selection. I have searched online and found out how...
6
by: phpnewbie26 | last post by:
My current form has one multiple select drop down menu as well as few other drop down menus that are single select. Originally I had it so that the multiple select menu was first, but this created...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.