Hello, I am having trouble with a problem. I started learning PHP yesterday, so please bear with me. =D
I have a database, and I have a webpage that populates an HTML table showing all the rows in a particular table. I am able to populate the table, but I also want the user to be able to delete the entries.
My idea was to store a “hidden” input type in each row of the table, and post the value of the hidden input type to the next screen. Each row has its own delete button. The code looks like this:
<?php
$result = mysql_query("SELECT * FROM item");
?>Item List:<br><table border="1"><th>Item</th><th></th><?php
while ($row = mysql_fetch_array($result)) {
?><tr><td><?php
echo $row['item'];
?></td><td><form action="delete_item.php" method="post"><input type="hidden" id="delete_item" value="<?php echo $row['id']?>"><input type="Submit" value="Delete"></form></td></tr><?php
}
?><tr><td colspan="3"><form action="create_new_item.php"><input type="Submit" value="Add New"></form></td></tr></table><?php
?>
The problem is, when I go to grab the value on the next screen:
$item_id= $_POST['delete_item'];
it doesn’t grab it. My assumption is because there are multiple inputs with the same id? I’m not sure.
Any help is greatly appreciated. Thank you.