need help adding the delete link to the table using the get method from the form
ID: 659738 • Letter: N
Question
need help adding the delete link to the table using the get method from the form and also need a form to add data to the sql table
$result = mysql_query("SELECT productName,listPrice,productID FROM products");
echo "<table border='1'>
<tr>
<th>Product</th>
<th>Price</th>
<th>Action</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['productName'] . "</td>";
echo "<td>" . $row['listPrice'] . "</td>";
echo "<td><a href="?product_id=<?php echo $product['productID'];?>">Delete</a></td>;
echo "</tr>";
}
echo "</table>";
mysql_close($con);
Explanation / Answer
$result = mysql_query("SELECT productName,listPrice,productID FROM products");
echo "<table border='1'>
<tr>
<th>Product</th>
<th>Price</th>
<th>Action</th>
<th>Delete</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>". $row[ 'productName' ] . "</td>";
echo "<td>" . $row[ 'listPrice' ] . "</td>";
echo "<td><a href="?product_id=<?php echo $product['productID'];?>">Delete</a></td>;
echo '<td><input type = "submit" name = "DeleteItem" value = " ' . $row[ 'id' ]. ' " /> </td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.