dseigqk7443 2014-02-15 13:36
浏览 31

php删除选项不起作用

hi i m trying to create a delete conformation box using php in my website but im getting some issues . if i click cancel button also its deleting the row in my database. The index page is designed in jquery

this is the php code which i have used for delete option?

<?php

    echo "<script language='javascript' type='text/javascript'>var x=confirm('Successfully Deleted!')</script>";

    if(x==true)
    {
    echo"deleted";
    include ("dbconnection.php");
$pid=$_GET['pid'];
$sql="DELETE FROM voters where id=$pid";
$res = mysql_query($sql) or die(mysql_error()); 
echo "<script language='javascript'  type='text/javascript'>window.open('index.php','_self')</script>";
}
else
{
echo"cancelled";
}
   ?>

this is my jquery code...

$str.="<thead><tr><th>ID</th><th>Card No</th><th>Name</th><th>Mob_num</th><th>Email</th><th>Action</th></tr></thead><tbody>";
                    while($row = mysql_fetch_array($res)){
                        $str.="<tr><td><center>".$row['id']."</center></td>";
                        $str.="<td>".$row['vcardno']."</td>";
                        $str.="<td>".$row['vname']."</td>";
                        $str.="<td>".$row['mob_num']."</td>";
                        $str.="<td>".$row['email']."</td>";
                        $str.="<td><center><a class='fancybox fancybox.ajax' href='viewstudent.php?ppid=".$row['id']."' onclick='return update()'><img src = 'images/view.png' height='30' width='30' alt = 'view' title = 'view'/></a><a class='fancybox fancybox.ajax' href='updatestudent.php?ppid=".$row['id']."' onclick='return update()'><img src = 'images/edit-icon.png' height='30' width='30' alt = 'edit' title = 'edit'/></a><a href='delete1.php?pid=".$row['id']."' onclick='return deleteItem()' ><img src = 'images/edit_delete.png' height='30' width='30' alt = 'delete' title = 'delete'/></a></center></td></tr>";
                    }

thanks..

  • 写回答

3条回答 默认 最新

  • duanhemou9834 2014-02-15 13:41
    关注

    x is a variable of jquery. You can't access it in php code. You need to access it via ajax call (this is the one way).

    评论

报告相同问题?

悬赏问题

  • ¥15 有人能看一下我宿舍管理系统的报修功能该怎么改啊?链表那里总是越界
  • ¥15 cs loadimage运行不了,easyx也下了,没有用
  • ¥15 r包runway详细安装教程
  • ¥15 Html中读取Json文件中数据并制作表格
  • ¥15 谁有RH342练习环境
  • ¥15 STM32F407 DMA中断问题
  • ¥15 uniapp连接阿里云无法发布消息和订阅
  • ¥25 麦当劳点餐系统代码纠错
  • ¥15 轮班监督委员会问题。
  • ¥20 关于变压器的具体案例分析