I am new to zend framework and want to delete data from database, but delete function is not working. Please help me out.
Here bis my controller code.
public function deleteAction()
{
if($this->getRequest()->isPost())
{
$del= $this->getRequest()->getPost('id');
if($del=="Yes")
{
$id =$this->getRequest()->getpost('id');
$client = new Application_Model_DbTable_Client();
$id = $this->getrequest()->getparam('id');
$client->deleteClient($id);
}
$this->_helper->redirector('index');
}
else
{
$id = $this->getRequest()->getparam('id');
$client = new Application_Model_DbTable_Client();
$this->view->client = $client->getclient($id);
}
}
Here is my model code.
public function deleteClient($id)
{
$this->delete('Id='.(int)$id);
}
Here is my delete.phtml file.
<form>
<p>Are you sure that you want to delete
<?php foreach($this->client as $clients): ?>
'<?php echo $this->escape($clients['firstname']); ?>'
'<?php echo $this->escape($clients['lastname']); ?>'
'<?php echo $this->escape($clients['email']); ?>'
</p>
<?php endforeach; ?>
<form action="<?php echo $this->url(array('action'=>'delete')); ?>" method="post">
<div>
<input type="hidden" name="id" value="<?php echo $this->escape($clients["Id"]); ?>"/>
<input type="submit" name="del" value="Yes" />
<input type="submit" name="del" value="No" />
</div>
</form>