I want to have a php file that can be used to edit, view, delete, and add new products. I have the viewing and adding new products parts done, but what I am trying to do now, is when you view the table that contains the database information have a button for editing, deleting, and adding new items. The code that I want to add to the buttons to is as follow:
<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>
If my question is not specific enough please let me know and I will try and narrow it down, but i am mainly looking for a push in the right direction so i can figure out what to do, because as of right now i am at a loss.
search about php add edit delete
see this tutorial about Basic PHP System: View/Edit/Delete/Add Records
(pagination part are optional)