doumao1047 2015-08-31 14:34
浏览 10

mysqli删除仅在第二个链接点击时工作

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!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 数学建模,尽量用matlab回答,论文格式
    • ¥15 昨天挂载了一下u盘,然后拔了
    • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
    • ¥20 易康econgnition精度验证
    • ¥15 msix packaging tool打包问题
    • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
    • ¥15 python的qt5界面
    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能