1 回答
TA贡献1828条经验 获得超3个赞
我对你的代码做了一些小改动,希望对你有帮助
<!-- [SEARCH FORM] -->
<form method="post">
<h1>
SEARCH FOR USERS
</h1>
<input type="text" name="search" required/>
<input type="submit" value="Search"/>
</form>
<!-- [SEARCH RESULTS] -->
<?php
if (isset($_POST['search'])) {
$stmt = $pdo->prepare("SELECT * FROM etcitem WHERE name LIKE ?");
$stmt->execute(["%" . $_POST['search'] . "%"]);
$results = $stmt->fetchAll();
if (count($results) > 0) {
echo("<table align='center' width='1800'>");
foreach ($results as $r) {
echo("<tr>");
echo("<td width='600' align='left'><img src='/Image/$r[name]'></td>");
echo("<td width='600' align='center'>$r[item_type]</td>");
echo("<td width='600' align='center'>$r[oldname]</td>");
echo("</tr>");
}
echo("</table>");
} else {
echo "No results found";
}
}
?>
- 1 回答
- 0 关注
- 85 浏览
添加回答
举报