Home>

html part:

<a href="__ url __/shanchu/id/{$vo.id}" onclick="return del ();">delete</a>

javascript part:

<script>
function del ()
{
  if (confirm ("Are you sure i want to delete?"))
  {
    return true;
  }
  else
  {
    return false;
  }
}
</script>

Controller part:

public function shanchu ()
{
  $id=$this->_request ("id");
  if ($id)
  {
    $user=m ("user");
    $data ["id"]=$id;
    $rs=$user->where ($data)->delete ();
    if ($rs)
    {
      $this->success ("Successfully deleted!");
    }
    else
    {
      $this->error ("Delete failed!");
    }
  }
  else
  {
    $this->error ("Delete failed!");
  }
}
php
  • Previous jQuery workaround to prevent duplicate binding events
  • Next How to add data in batch in Yii2