MySQL和查询不能从PHP文件工作


MySQL AND Query Not Working From PHP File

这真的很困扰我,因为我已经得到这个工作在phpmyadmin,但不能得到它的工作从我的php脚本

下面的代码是一个基本的php文件(我正在学习),其中用户在表单中提交零件号和订单号,然后将其传递给查询(通过变量),查询结果返回到同一页面中的表。

当只传递部分变量$input时,我可以让它正常工作,但是当我传递AND标准时,没有返回结果。我已经检查了一遍又一遍,表和组合测试应该工作。我试过硬编码零件号和订单号组合,同样的情况发生(好吧,只是部分,但不是当你添加and部分)。在phpmyadmin上测试这个零件和订单组合会得到预期的效果。我错过什么了吗?

<?php include 'database.php' ; ?>
<?php
$input =$_GET['part'];
$ord = $_GET['order'];
// This query works fine with just the $input criteria but when I add AND 'Order' etc... it produces zero results.
$query = "SELECT * FROM `part_status` WHERE `Part` = '$input' AND `Order` = '$ord'";
$result = $conn->query($query);
$status = $result->fetch_assoc();
?>
<!DOCTYPE html>
<html>
<head>
    <title>Part Archive</title>
</head>
<body>
<!-- Form for submitting the two criteria of the query -->
<form method="get" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
    Part Number: <input type="text" name="part" value="<?php echo $part;?>" placeholder="Enter part number">
    Order: <input type="text" name="order" value="<?php echo $order;?>" placeholder="Enter order number">
    <input type="submit">
</form>
<header><h1>Orders For: <?php echo $input;?></h1></header>
<!-- Table for displaying the result of the slq query at the top -->
<table>
    <tr><th>Part</th><th>Qty</th><th>Due Date</th><th>Order No.</th></tr>
    <?php while($row = $result->fetch_assoc()) : ?>
        <tr><td><?php echo $row['Part']; ?></td><td><?php echo $row['Qty']; ?></td><td><?php echo $row['Due Date']; ?></td><td><?php echo $row['Order']; ?></td></tr>
    <?php endwhile ;?>
</table>
</body>
</html>

永远感激任何指示或建议。

感谢@dbarthel提供的解决方案…
我删除了$status = $result->fetch_assoc();和while循环,用<?php $row = $result->fetch_assoc()) ; ?>替换<?php while($row = $result->fetch_assoc()) : ?><?php endwhile ;?>,这返回了表格中所要求的记录。

感谢所有人的帮助和支持。现在我可以继续,并尝试进一步发展。