Title1

Title2

Title3

12-4 刪除記錄

一、流程


  #刪除記錄
  case "op_delete":
    op_delete($sn);
    redirect_header("index.php",3000,"刪除記錄成功!!");
    exit;
  break;

二、函數


###############################################################################
#  刪除資料
###############################################################################
function op_delete($sn="")
{
  global $mysqli;
  if(!$sn)redirect_header("index.php",3000,"刪除記錄錯誤!!");

  #檢查
  $sql = "delete
          from `show_kind`
          where `sn`='{$sn}'";//die($sql);
  $mysqli->query($sql) or die(printf("Error: %s <br>".$sql, $mysqli->sqlstate));

  return;
}

三、樣板(列表的樣板)

{literal}   
  <link rel="stylesheet" href="../class/sweet-alert/sweet-alert.css" type="text/css" />  
  <script src="../class/sweet-alert/sweet-alert.js" type="text/javascript"></script>
  <script type="text/javascript"> 
    function op_delete_js(sn){
      swal({
        title: '確定要刪除此資料?',
        text: '相關資料通通都將會被移除!',
        type: 'warning',
        showCancelButton: 1,
        confirmButtonColor: '#DD6B55',
        confirmButtonText: '確定刪除!',
        closeOnConfirm: false ,
        allowOutsideClick: true
      },
      function(){
        location.href='nav_m.php?op=op_delete&sn=' + sn;
      });
    }            
  </script>
{/literal}

                  <button onclick="javascript:op_delete_js({$row.sn});" type="button" class="btn btn-danger">刪除</button>