Solved

Retruve the multiple value from the select multiple tag in PHP

Posted on 2004-04-06
4
233 Views
Last Modified: 2010-04-17
Hi Experts,

    I have an html file which has a select tag with multiple selection and i want to get the selected multiple value from that html file to the php file

 html file is as follows

<html>
<body>
<select name = "option" multiple>
<option>one</option>
<option>two</option>
<option> three</option>
</select>
</body>
</html>

PHP file is as follows

<?php

    $selectvalue = $_POST['option'];

?>

but in this php file i'm getting only one value and i'm nit getting multiple value.

Please help me out to solve this .
 or give me some example that would help me out

Thanx

0
Comment
Question by:mohan21_kumar
4 Comments
 
LVL 1

Expert Comment

by:gourav_jain
ID: 10772489
Hi,

use @selectvalue = $_POST['option'] instead, this will give you the array of all the values of your form variable "option".

Gourav Jain
0
 
LVL 28

Accepted Solution

by:
peakpeak earned 25 total points
ID: 10772636
In the form definition you need brackets after the name to define an array

<select name="option[]" multiple>

In the php script you then extract the values as follows:

<?php
$option = $_POST['option'];
foreach($option as $selected)
{
        print $selected." / ";
}       
?>

Regards
Peter
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now