Hi!
Just wanted to know if there is any special syntax to get values in <option> with a space between words.
For example:
<form action="abc.php" method="post">
<select name="study_class">
<option value="Class 1">CLASS 1</option>
<option value="Class 2">CLASS 2</option>
</select>
</form>

Can php recognize "Class 1" or "Class 2" or will it recognize only "Class" or "Class".

Thanks!

No, it should recognise "Class 1", "Class 2"..

<?php

  $study = $_POST['study_class'];

  var_dump($study);
?>

Then depending on whichever value is entered, should assign this.

I haven't tested it though, might be wrong!

Perfect!!!!! worked :)
Thanks!

Well..phorce..it works. But now it outputs the crude values like:
string(31)"Class 1, Class 2"
I don't want var_dump($study); to give any output on its own except to pass on all data

<form action="abc.php" method="post">
    <select name="study_class[]" multiple>
        <option value="Class 1">CLASS 1</option>
        <option value="Class 2">CLASS 2</option>
        <option value="Class 3">CLASS 1</option>
        <option value="Class 4">CLASS 2</option>
    </select>
</form>

abc.php
<?php
#get data
$study_class=implode(', ', $_POST['study_class']);
var_dump($study_class);
?>
<html>
.
.
<P> Study Classes Chosen are: <?php echo $study_class; ?></P>
.
</html>

OUTPUT:
string(31)"Class 1, Class 2"

Study Classes Chosen are: Class 1, Class 2

So, I do not want the 'string....' line to come up.
Moreover, in the php i would also be passing the multiple choices via mail.

answer is to remove var_dump($study_class); and it will work!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.