How can a link be automatically generated to delete a record in a database using PHP?
To automatically generate a link to delete a record in a database using PHP, you can pass the record's ID as a parameter in the link URL. Then, in the PHP script that processes the deletion, you can retrieve the ID from the URL and use it to delete the corresponding record from the database.
<?php
// Generate link to delete record with ID 123
$record_id = 123;
$delete_link = "delete_record.php?id=" . $record_id;
// In delete_record.php
if(isset($_GET['id'])) {
$record_id = $_GET['id'];
// Code to delete record with $record_id from database
}
?>