weixin_33681778 2014-12-04 13:12 采纳率: 0%
浏览 10

PHP Ajax下拉框

<?php
require ("init.php");

?>
<head>
<script src="ajax.js"></script>
<script src="common.js"></script>
</head>
<body>
<?php
$query = "SELECT * FROM User1";
$result = mysqli_query($connection, $query);
echo '<form> ';
echo "Select a Users:"; 
echo '<select name="users" onchange="showUser(this.value)">';
while ($row=mysqli_fetch_assoc($result)){
    echo $row=['Username'];
    echo '<option value="'.$row=['Username'].'">'.$row=['Username'].'</option>';
}
echo '</select></form>';
?>

<div id="txtHint"><b>User info will be listed here.</b></div>

</body>

the problem i am having is that the drop down box only shows array multiple times and does not show usernames from my database however the connection to my database is working as when tryed debugging it got it to echo out just one username

  • 写回答

2条回答 默认 最新

  • Memor.の 2014-12-04 13:14
    关注

    IT should be like this:

    while ($row=mysqli_fetch_assoc($result)){
        //echo $row=['Username']; //Invalied here
        echo '<option value="'.$row['Username'].'">'.$row['Username'].'</option>';
    }
    

    No need that =sign.

    评论

报告相同问题?

悬赏问题

  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程