title: How to use jQuery confirm box to delete a row from database in zend?
body: <p>I am new to Zend Framework and jQuery. I am trying to delete a row from database on the basis of the returned value of <code>confirm()</code>. But the problem I am having is that if I press yes or no both times the selected row is deleted. I need to confirm that only when I press yes that only the selected row will be deleted. One thing I am using Zend Framework.</p>
  
  <p>My codes are given below:</p>
  
  <h2>index.phtml</h2>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;style type="text/css" rel="stylesheet"&gt;
  #simplemodal-overlay {background-color:#000;}
  #simplemodal-container {background-color:#333; border:8px solid #444; padding:12px;}
  #simplemodal-container a.modalCloseImg {
      background:url(x.png) no-repeat; /* adjust url as required */
      width:25px;
      height:29px;
      display:inline;
      z-index:3200;
      position:absolute;
      top:-15px;
      right:-18px;
      cursor:pointer;
  }
  
  &lt;/style&gt; 
  &lt;script type="text/javascript" src="/jQuery.js"&gt; &lt;/script&gt;
  &lt;script type="text/javascript" src="/jquery.simplemodal-1.4.2.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  
  
  $(document).ready(function(){
      //alert("test");
      $(".delete").click(function(e){
          //$('p').attrib('id');
          //e.preventDefault();
          //$("#deleteForm").modal();
          if(confirm("test"));
  
      });
  
      });
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;center&gt;
  &lt;?php         
  echo "Student List";
  
  ?&gt;
  &lt;p&gt;&lt;a href="&lt;?php echo $this-&gt;url(array('controller'=&gt;'index', 
          'action'=&gt;'add'));?&gt;"&gt;Add new student&lt;/a&gt;&lt;/p&gt;
  &lt;table border="1"&gt;
  &lt;tr&gt;
      &lt;th&gt;Name&lt;/th&gt;
      &lt;th&gt;Email&lt;/th&gt;
      &lt;th&gt;Phone&lt;/th&gt;
      &lt;th&gt;Action&lt;/th&gt;
  &lt;/tr&gt;
  &lt;?php foreach($this-&gt;students as $student) : ?&gt;
  &lt;tr&gt;
  
      &lt;td&gt;&lt;?php echo $student-&gt;name;?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $student-&gt;email;?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $student-&gt;phone;?&gt;&lt;/td&gt;
  
      &lt;td&gt;
          &lt;a href="&lt;?php echo $this-&gt;url(array('controller'=&gt;'index', 
              'action'=&gt;'edit', 'id'=&gt;$student-&gt;id));?&gt;"&gt;Edit&lt;/a&gt;
          &lt;a class="delete" href="&lt;?php echo $this-&gt;url(array('controller'=&gt;'index', 
              'action'=&gt;'delete','id'=&gt;$student-&gt;id));?&gt;"&gt;Delete&lt;/a&gt;
      &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;?php endforeach; ?&gt;
  &lt;/table&gt;
  
  &lt;/center&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <h2>IndexController.php</h2>
  
  <pre><code>&lt;?php
  
  class IndexController extends Zend_Controller_Action
  {
  
      public function init()
      {
          /* Initialize action controller here */
        //  $test = new Application_Model_DbTable_Email();
  
      }
  
      public function indexAction()
      {
            $this-&gt;_helper-&gt;layout-&gt;disableLayout();
          $students = new Application_Model_DbTable_Students();
          $this-&gt;view-&gt;students = $students-&gt;fetchAll();
      }
  
      public function addAction()
      {
          $form = new Application_Form_Student();
          $form-&gt;submit-&gt;setLabel('Add');
          $this-&gt;view-&gt;form = $form;
  
          if ($this-&gt;getRequest()-&gt;isPost()) {
              $formData = $this-&gt;getRequest()-&gt;getPost();
              if ($form-&gt;isValid($formData)) {
                  $name = $form-&gt;getValue('name');
                  $email = $form-&gt;getValue('email');
                  $phone = $form-&gt;getValue('phone');
                 // $image = $form-&gt;getValue('image');
                  $students = new Application_Model_DbTable_Students();
                  $students-&gt;addStudent($name, $email,$phone);
  
                  $this-&gt;_helper-&gt;redirector('index');
              } else {
                  $form-&gt;populate($formData);
              }
          }
  
      }
  
      public function editAction()
      {
          $modelStudents = new Application_Model_DbTable_Students();
          $id = (int) $this-&gt;_getParam('id');
  
          $student = $modelStudents-&gt;fetch($id);
  
          $form = new Application_Form_Student($student-&gt;email);
          $form-&gt;submit-&gt;setLabel('Save');
          $this-&gt;view-&gt;form = $form;
         if ($this-&gt;getRequest()-&gt;isPost()) {
              $formData = $this-&gt;getRequest()-&gt;getPost();
              if ($form-&gt;isValid($formData)) {
                  $id = (int)$form-&gt;getValue('id');
                  $name = $form-&gt;getValue('name');
                  $email = $form-&gt;getValue('email');
                  $phone = $form-&gt;getValue('phone');
                  $students = new Application_Model_DbTable_Students();
                  $students-&gt;updateStudent($id, $name, $email, $phone);
  
                  $this-&gt;_helper-&gt;redirector('index');
              } else {
                  $form-&gt;populate($formData);
              }
          } else {
              $id = $this-&gt;_getParam('id', 0);
              if ($id &gt; 0) {
  
                  $form-&gt;populate($modelStudents-&gt;getStudent($id));
              }
          }
  
      }
  
      public function deleteAction()
      {
  
                  //$id = $this-&gt;getRequest()-&gt;getPost('id');
              $students = new Application_Model_DbTable_Students();
              $id = $this-&gt;_getParam('id', 0);
              $students-&gt;deleteStudent($id);
              $this-&gt;_helper-&gt;redirector('index');
  
      }
  
      //echo $test;
  
  }
  </code></pre>
  
  <p>Thanks in advance,
  enamul</p>