在下拉列表中排除状态

fwzugrvs  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(311)

我试图排除所有 status 在我的mobo表中有缺陷,但此代码不起作用。
它仍然显示我下拉列表中的所有内容

<?php
$conn = new mysqli('localhost', 'root', 'admin2018', 'inventory') 
or die ('Cannot connect to db');
    $result = $conn->query("select mobo, status FROM mobo WHERE NOT 'status = Defective'");
    echo "<select name='mobo'>";

    while ($row = $result->fetch_assoc()) {

                  unset($id, $name);
                  $id = $row['mobo'];
                  $name = $row['mobo'];
                  echo '<option value="'.$id.'">'.$name.'</option>';

}
    echo "</select>";
?>
arknldoa

arknldoa1#

不用担心,我已经用

<?php
$conn = new mysqli('localhost', 'root', 'admin2018', 'inventory') 
or die ('Cannot connect to db');
    $result = $conn->query("select mobo, status FROM mobo WHERE status!='Defective'");
    echo "<select name='mobo'>";

    while ($row = $result->fetch_assoc()) {

                  unset($id, $name);
                  $id = $row['mobo'];
                  $name = $row['mobo'];
                  echo '<option value="'.$id.'">'.$name.'</option>';

}
    echo "</select>";
?>

相关问题