lamloumi
lamloumi

Reputation: 77

Value of string with space

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'].

Upvotes: 2

Views: 432

Answers (2)

hatkirby
hatkirby

Reputation: 850

You need to surround

<?php echo($states[$i][0]); ?>

with quotation marks.

Upvotes: 0

Mike B
Mike B

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

Related Questions