You need to write your deleteEntry() function in functions.inc.php. This function needs to accept the entry URL as an argument, then place that URL into a DELETE query that removes a maximum of one entry from the entries table.
Your MySQL query should read like this:
DELETE FROM entries WHERE url=? LIMIT 1
After you prepare the statement for execution, you use your supplied URL to execute the argument. You can make sure that the function executes successfully by returning the value of $stmt->execute() as the return value of your function.
Add your deleteEntry() function below retrieveEntries() in functions.inc.php:
function deleteEntry($db, $url) { $sql = "DELETE FROM entries WHERE url=? LIMIT 1"; $stmt = $db->prepare($sql); return $stmt->execute(array($url)); }
You can now delete entries from the database. You can test this by creating a temporary entry (see Figure 7-5), then deleting it to see whether it is removed from the database and, therefore, from your entry list (see Figure 7-6).
3.147.80.100