0

我有一个带有下拉列表的表格。我收到返回值的电子邮件,下拉选择除外。它是空白的,而不是显示选择的内容。这是我的html

Item Type<span style="color: #FF0000">*</span>
<select name="items" class="items" id="items">
   <option value="0">Please Select</option>
   <option value="1">Gold</option>
   <option value="2">Silver</option>
   <option value="3">Watch</option>
   <option value="4">Electronics</option>
   <option value="5">Tools</option>
   <option value="6">Lawn Equipment</option>
   <option value="7">Guns</option>
   <option value="8">Musical Instrument</option>
   <option value="9">Car</option>
   <option value="10">Recreational Vehicle</option>
   <option value="11">Collectible</option>
   <option value="12">Other</option>
 </select>

这是我的 php

    $name = $_POST['name']; // required
    $email_from = $_POST['email']; // required
    $phone = $_POST['phone']; // required
    $comments = $_POST['comments']; // required
$servicetype = array("pawn" => false, "buy" => false);  //checkboxes
$items= $_POST['items'];

     $items= array (1=>'Gold', 'Silver', 'Watch', 'Electronics',  //item array
'Tools', 'Lawn Equipment', 'Guns', 'Musical Instruments',
'Car', 'Recreational Vehicle', 'Collectible', 'Other');
{   echo'<select name="items">'; 

     // For each value of the array assign variable name "item" 
         foreach ( $items as $key => $value ) { 
            echo"<option value=\"$key\">$value</option>\n";
         }
         echo'</select>';     
     }
//EMAIL MESSAGE DETAILS     
$email_message .= "Name: ".clean_string($name). "\r\n";
$email_message .= "Email: ".clean_string($email_from). "\r\n";
$email_message .= "Phone: ".clean_string($phone). "\r\n";
$email_message .= "Pawn: " . clean_string(($servicetype["pawn"]) ? "Yes" : "No"). "\r\n";
$email_message .= "Buy: " . clean_string(($servicetype["buy"]) ? "Yes" : "No") . "\r\n";
$email_message .= "Item Type: ".clean_string($items). "\r\n";
$email_message .= "About My Item: ".clean_string($comments). "\r\n";

谢谢

4

1 回答 1

1

您的 html 已损坏:

<select name="items" class="items" id="items" ;">
                                              ^^----
于 2013-10-08T18:52:06.453 回答