Question: I need help figuring out how to add a delete button to my php file. In my index.php I have a delete button for each
I need help figuring out how to add a delete button to my php file. In my index.php I have a delete button for each record that is in the database. For some reason I can't get mine to work. Can someone help me figure out why?
database.php:
$dsn ="mysql:host=localhost; dbname=ToDoList";
$username = 'root';
$password = '4895698As';
try
{
$db = new PDO($dsn, $username, $password);
} catch (PDOException $e)
{
$error_message = 'Database Error!';
$error_message .= $e->getMessage();
echo $error_message;
exit();
}
?>
index.php:
require('database.php');
//post data
$newTitle = filter_input(INPUT_POST, 'newTitle', FILTER_UNSAFE_RAW);
$description = filter_input(INPUT_POST, 'description', FILTER_UNSAFE_RAW);
//Get Data
$title = filter_input(INPUT_GET, 'tile', FILTER_UNSAFE_RAW);
$query = 'SELECT * FROM todoitems';// PUT YOUR SQL QUERY HERE
// Example: $query = 'SELECT * FROM customers';
$statement = $db->prepare($query);
$statement->execute();
$results = $statement->fetchAll();
$statement->closeCursor();
?>
ToDoList
| Title | Description |
|---|---|
Sorry No Results!
Add Item:
