我目前有一个 HTML 搜索表单,需要多个输入(例如:123456、654321、789456)。我正在使用 PHP 搜索数据库,查看这些数字是否作为项目编号存在。然后,它会在回显表中返回有关这些项目的信息。
唯一的问题是,如果数据库中不存在某个数字,即使其他两项存在,也不会返回任何结果。
我怎样才能拥有它,以便它返回有关确实存在的项目的信息,然后列出无法找到其记录的项目?
我的表格和表格生成如下:
<div id="div1">
<!-- [SEARCH FORM] -->
<form method="post" action="nweb.php" id="testform">
<h1>Product Information</h1>
<!-- <input type="text" name="search" required/> -->
<textarea name="search" cols="40" rows="5" form="testform"></textarea>
<input type="submit" value="Search"/>
</form>
<?php
if (isset($_POST['search'])) {
// SEARCH FOR ITEMS
require "2-search.php";
// DISPLAY RESULTS
if (count($results) > 0) {
echo "number found ".count($resultsArray)."<br>";
echo "<table>";
echo "<thead>";
echo "<tr>";
echo "<th>Item number</th>";
echo "<th>Stock available</th>";
echo "<th>Available Stock</th>";
echo "<th>Detailed Description</th>";
echo "<th>Division</th>";
echo "<th>Gender</th>";
echo "<th>Group</th>";
echo "<th>Subgroup</th>";
echo "</tr>";
echo "</thead>";
foreach ($resultsArray as $results) {
foreach ($results as $r) {
echo "<tbody>";
echo "<tr>";
echo "<td>". $r['item_number'] ."</td>";
echo "<td>". $r['stock_available'] ."</td>";
echo "<td>". $r['available_stock'] ."</td>";
echo "<td>" . $r['detailed_desc'] . "</td>";
echo "<td>" . $r['division'] . "</td>";
echo "<td>" . $r['gender'] . "</td>";
echo "<td>" . $r['group'] . "</td>";
echo "<td>" . $r['sub_group'] . "</td>";
echo "</tr>";
echo "</tbody>";
}
}
echo "</table>";
} else {
echo "No results found";
}
}
?>
</div>
如果有人可以提供帮助,我们将不胜感激。
拉风的咖菲猫