dongmo8943 2014-07-30 03:23
浏览 9
已采纳

组合框不能将id添加到选项值[关闭]

dropdown box is not adding the $id to the value=/customer when selected and goes to the url. It just shows the /customer page but would like it to show .../customer$id as to load their specific page. Thank you for your help

<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);
?> 
  • 写回答

1条回答 默认 最新

  • duan19805 2014-07-30 03:27
    关注

    Your issue lies here:

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

    You're closing off the value attribute with that extra ".

    Do this instead.

    echo '<option value="/customer'.$id.'">'.$name.','.$firstname.'</option>';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入