I want to know if there is a better way to find if a row was deleted using PDO. What am I doing now is to read first from database and then delete. If read operation returns content I display success message and if not I display data not fount message.
This is my code:
$find_it = 0;
$content = $cancel_db->select_all_general("SELECT * FROM dm_bookings WHERE id = '$c_reference' AND email = '$c_email'");
foreach ($content as $row){
$find_it = 1;
}
$cancel_db->insert_update_delete_general_no_m("DELETE FROM dm_bookings WHERE id = '$c_reference' AND email = '$c_email'");
if($find_it == 1) {
$div_class = "alert-success";
$mesaj = "<br />Booking deleted!<br /><br />";
} else {
$div_class = "alert-danger";
$mesaj = "<br /Booking not finded!<br /><br />";
}
Is there a way to improve this? Thanks.