I have a table with all the articles looped out from the database along with a DELETE link that sends the ID of the post to the handler for deletion, but I have to click twice for it to delete.
Here's the deletion code in the handler:
if($_GET['deleteArticleId']){
// Delete article
$crudObject = new CrudClass();
$row_id = $_GET['deleteArticleId'];
$table_name = "28uge_cms_newsarticles";
$crudObject->delete($table_name, $row_id);
// Delete article links to categories
$crudObject = new CrudClass();
$sql = "DELETE FROM 28uge_cms_newsarticles_categories WHERE newsarticles_id = {$_GET['deleteArticleId']}";
$crudObject->sendQueryToDatabase($sql);
// Delete article links to images
$crudObject = new CrudClass();
$sql = "DELETE FROM 28uge_cms_newsarticles_images WHERE newsarticles_id = {$_GET['deleteArticleId']}";
$crudObject->sendQueryToDatabase($sql);
header('location: ../admin/newsview.php');
exit;
}
"// Delete article links to categories" and "// Delete article links to images" works the first time around, but the "// Delete article" only works when the delete link has been pressed twice.
Here's the delete function code:
public function delete($table_name, $row_id){
// Putting together the SQL string.
$sql = "DELETE FROM $table_name WHERE id = $row_id";
// Sending the SQL string off to the database.
$this->dbConn -> query($sql);
}
I can't figure out what is causing this bug, so help would be greatly appreciated!