我想要一个可用于编辑、查看、删除和添加新产品的 php 文件。我已经完成了查看和添加新产品部分,但我现在要做的是,当您查看包含数据库信息的表时,有一个用于编辑、删除和添加新项目的按钮。我要添加到按钮的代码如下:
<html>
<head>
<style type="text/css">
td
{
padding:15px;
}
</style>
</head>
<?php
$mysqli = new mysqli("localhost","herp","lerp","derp");
$search=$_POST['search'];
$searchoption=$_POST['searchoption'];
$query= "SELECT * FROM contacts WHERE $searchoption = '".$search."'";
$result = $mysqli->query($query);
if (!$result) {
printf("Query failed: %s\n", $mysqli->error);
exit;
}
?>
<table>
<th> Information</th>
<?php
while ($contact = $result ->fetch_assoc()) {
echo "<tr>";
echo "<th> Item Number </th>";
echo "<th> Item Name </th>";
echo "<th> Description </th>";
echo "<th> Inventory </th>";
echo "<th> Price </th>";
echo "<th> Active or Non-Active </th>";
echo "<th> Photo </th>";
echo "</tr>";
echo "<tr>";
echo "<td>".$contact['item_number']."</td>";
echo "<td>".$contact['item_name']."</td>";
echo "<td>".$contact['item_description']."</td>";
echo "<td>".$contact['item_inventory']."</td>";
echo "<td>".$contact['item_price']."</td>";
echo "<td>".$contact['item_active_or_nonactive']."</td>";
echo "<td>".$contact['item_photo']."</td>";
echo "</tr><br/>";
}
?>
</table>
</html>
如果我的问题不够具体,请告诉我,我会尝试缩小范围,但我主要是在寻找正确方向的推动力,这样我才能弄清楚该怎么做,因为截至目前我处于损失。