Forum Moderators: coopster
function deletepart($part) {
$q = "DELETE FROM inventory WHERE part = '" . $part . "'";
$db->execute($q);
}
foreach($inventory as $i)
$str .= "<tr><td>" . $i['part'] . "</td><td><a href=\"deletepart(" . $i['part'] . ")\">delete this part</a></td></tr>\n";
echo "<table>\n" . $str . "</table>\n";
The problem of course is in the <a href>-tag: it will lead to a new page, but I only want to manipulate the database $db. So without using buttons, how can I make the hyperlink act as a button? I am happy to wrap the table in a form, as long as it does not contain any Javascript.
Thanks in advance
Tech
Why can't you make the link the same page as the page you are listing the delete links and send the ID for the part to be deleted as a parameter. Something like (check the code for the link):
function deletepart($part) {
$q = "DELETE FROM inventory WHERE part = '" . $part . "'";
$db->execute($q);
}
if($_GET['part'])
{deletepart($_GET['part']);}
foreach($inventory as $i)
$str .= "<tr><td>" . $i['part'] . "</td><td><a href=\"deletepart.php?part=" . $i['part'] . "\">delete this part</a></td></tr>\n";
echo "<table>\n" . $str . "</table>\n";
HTH, Jenny