组合框没有将id添加到选项值


combo box not not adding id to option value

下拉框没有添加$id到value=/customer,当选中并转到url时。它只是显示/客户页面,但希望它显示…/customer$id作为加载他们的特定页面。谢谢你的帮助

<select type="text" class="form-control" placeholder="Customer Lookup" onchange="window.location=this.options[this.selectedIndex].value">
<option>Customers</option>
<?php
require ('dbconnect.php');
$result = $con->query("select id, lastname, firstname from customer");
while ($row = $result->fetch_assoc()) {
unset($id, $name);
$id = $row['id'];
$name = $row['lastname'];
$firstname = $row['firstname']; 
echo '<option value="/customer"'.$id.'">'.$name.','.$firstname.'</option>';
}
echo "</select>";
mysqli_close($con);
?> 

你的问题在这里:

echo '<option value="/customer"'.$id.'">'.$name.','.$firstname.'</option>';
                              ^

您将使用额外的 " 关闭value属性。

改为

echo '<option value="/customer'.$id.'">'.$name.','.$firstname.'</option>';