Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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=&lt;?php echo $product['productID'];?&gt;">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=&lt;?php echo $product['productID'];?&gt;">Delete</a></td>;

echo '<td><input type = "submit" name = "DeleteItem" value = " ' . $row[ 'id' ]. ' " /> </td>";

echo "</tr>";

}

echo "</table>";

mysql_close($con);