Reputation: 77
I have a form contains this list:
<tr>
<td>State/Province: </td>
<td colspan="3">
<select style="width:200px" name="state">
<option value="All">All</option>
<?php for( $i=0;$i<sizeof($states);$i++) { ?>
<option value=<?php echo($states[$i][0]) ;?>>
<?php echo( $states[$i][0]) ;?>
</option>
<?php }?>
</select>
</td>
</tr>
My problem is the value of state
when the choice is composed by two or more words. For example if I have the word "New York: only the word "New" is stored in $_POST['state']
.
$_POST['state']
?Upvotes: 2
Views: 432
Reputation: 850
You need to surround
<?php echo($states[$i][0]); ?>
with quotation marks.
Upvotes: 0
Reputation: 32155
Quotes around the value
<option value="<?php echo($states[$i][0]) ;?>">
<option value=New York> // No good
<option value="New York"> // Better
Upvotes: 8