Solved

could not get all selected values from list box (multiple)

Posted on 2006-07-09
4
1,207 Views
Last Modified: 2012-06-27
I am using PHP5, my problem is i did get all selected valuse from the list box. once i submit the form i did get all selected values from the list box.
if i say       echo $_POST['jobsector'; I am geting only one value for example if select all three valuse from the list box i am getting only last value. pls help me.

echo "<form action='registration.php' method=POST ENCTYPE='multipart/form-data'>";
echo "<table><tr><td  >  Preferred Job Sector * </td>";
      echo "    <td WIDTH='58%' VALIGN=TOP>
      <Select Size=4 Multiple name='jobsector'>
            <option value='Administration'>Administration</option>
            <option value='Commercial Management'>Commercial Management</option>
            <option value='Corporate Affairs'>Corporate Affairs</option>
       </Select></td></tr>";
echo "<tr><td ><INPUT TYPE='submit' name='submit' value='submit'></td>";
      echo "</tr></table>";
echo "</form>";
0
Comment
Question by:jessi_vs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 29

Assisted Solution

by:TeRReF
TeRReF earned 25 total points
ID: 17070827
Change this:
    <Select Size=4 Multiple name='jobsector'>
to
    <Select Size=4 Multiple name='jobsector[]'>

Now it's an array with all selected values:
print_r($_POST['jobsector']);
0
 
LVL 2

Accepted Solution

by:
arun80_inin earned 25 total points
ID: 17071042
If you are using multiple select box the name should be end with []
ex:jobsector[]

If you give the name like this then you can use the following code in php to get all the values

for (i=0;i<count($_POST['jobsector'];$i++)
{
     echo $_POST['jobsector'][$i];
}
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 17071074
That's pretty much what I said :)
0
 

Author Comment

by:jessi_vs
ID: 17071224
TeRReF's command is good enough to solve my problem. arun's comment is very informative. Thank you all.
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question