?
Solved

Retruve the multiple value from the select multiple tag in PHP

Posted on 2004-04-06
4
Medium Priority
?
261 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
2 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 100 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
Make the most of your online learning experience.
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…
Six Sigma Control Plans

839 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