douxiexie3574 2015-06-08 19:59
浏览 13

我如何从MySQL表中删除行

I have a problem preventing me from proceeding on my project. I fail to understand what is wrong until a certain row id cannot be deleted when the query is run.

My code, step by step:

(1) This is the button code, which once I click it emits a popup message to confirm delete, and once I confirm delete (OK), on browser it shows as if the row deleted (disappear) and when I refresh the page, data appears again which means it is not deleted.

<input type="button" onclick='return deletethis(this)' class="btn btn-
triangle btn-red" value="X">

(2) And the java code:

<script type="text/javascript">
function deletethis(el){
    var e = $(el).parent().attr('id');
    var cnf = confirm('Are you sure, you want to delete?');
    if(cnf == true){
        $(el).parent().parent().hide(1000);
        $.post('deleteAdd.php', {id:e}, function(data){

        });
       }
     }
   </script>

(3) This is "deleteAdd.php" file which holds PHP code for deleting

<?php
  global $database;
  $uid = $_POST['id'];

  $q = "DELETE FROM sale_daily WHERE id=$uid";
  $r = $database->query($q);
  $rw = $database->fetch_array($r);
  ?>
  • 写回答

1条回答 默认 最新

  • duanbei7035 2015-06-08 20:07
    关注

    You are passing the wrong id value.

    change this line of code:

    var e = $(el).parent().attr('id');

    to

    var e = $(el).parent().attr('value');

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度