I'll add this snippet in to prevent accidental deletes:
<a href="delete.php?id=' . $row[id] . ' onClick='return confirm(\"Do you really want to delete this record?\")' ">' . $row[name] . '</a>
On Wednesday, June 5, 2002, at 09:20 AM, Gary.Every@ingramentertainment.com wrote:
One way to do it would be thusly:
$result=mysql_query(yadayada);
foreach($result as $row){
echo '
<tr><td>
<a href="delete.php?id=' . $row[id] . '">' . $row[name] . '</a>
...
</tr>';
}
This would set up a url that when the user clicks on $row[name] (such as
"Record Description" it would call delete.php with the argument of $row[id]
Within that delete.php, you remove the selected record, then call the
original page.
Use:
$sql="DELETE from table where id=$id";
Then do:
echo '
Header("Location: original_location.php");
You can't have any html previous to the Header command, though.
This will return you to your original page where you can do your select
again, and the deleted row won't show up.
You may need to pass parameters on the Header line to let
original_location.php exactly where you were previously. This would have to
be passed either on the url or as a post/get operation when first calling
delete.php