dqusbxh44823 2013-08-28 16:32
浏览 68

我想在使用复选框删除数据之前显示确认消息

I have a problem displaying the confirmation message before deleting a data

if(isset($_POST['del'])){
        echo "
            <script>
                var x;
                    x = confirm ('You want to proceed deleting?');

                    if(x == true){";
            for($i=0;$i<$_SESSION['count'];$i++){
            $checkbox = $_POST['checkbox'];
            $del_id = $checkbox[$i];
            $query = mysql_query("SELECT picture FROM tblreserve WHERE id='$del_id'");
            while($row = mysql_fetch_assoc($query)){
                $del_pic = $row['picture'];
            }
            $sql = "DELETE FROM tblreserve WHERE id = $del_id";
            $result = mysql_query($sql);
            if($result){
                if(is_file($del_pic)){
                        unlink($del_pic);
            }
    }
    }
    header('location:view.php');

                    echo "}
                    else{
                        location.href = 'view.php';
                        }
                    </script>";
    }
  • 写回答

2条回答 默认 最新

  • dongwei3712 2013-08-28 16:43
    关注

    When the confirmation box prompted in your browser, all your php code is all parse in the file. Delete the data in mysql is via php, so you want to confirm this by clicking the javascript prompted button, you should refresh your page by sending a tag in from url, or you can implement it via ajax. In you given snippet, php can not be halted there by the javascript confirm. You should know one is server end, the other is client-end

    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b