Apply for Zend Framework Certification Training

Zend Framework 1




Step 1  Create an list Action method in Controller 
public function listAction()
{
    	$auth = Zend_Auth::getInstance(); // if you want  Autenticated user to see list
    	if(!$auth->hasIdentity())
    	{
    		$this->_redirect("/index/loginform");
    	}
    	$params = array('host'=>"localhost","username"=>"root",
                                  "password"=>"","dbname"=>"zend");
    	$db = new Zend_Db_Adapter_Pdo_Mysql($params);
    	$sql="select * from employee";
    	$result = $db->fetchAssoc($sql);
    	$this->view->assign('data',$result);
}

Step 2 Create an list.phtml file to display data
<div id="content">
<table align="center">
<tr><td><a href="logout">Logout</a></td></tr>
<tr><th> Employee Detail list</th></tr>
  <tr>
    <th>Employee Id</th>
    <th>First Name</th>
    <th>Last Name</th>
    <th>Email</th>
    <th>User name</th>
  </tr>
<?php 
$datas =$this->data;
//print_r($datas);
foreach ( $datas as $data)
{
	echo "<tr><td>".$data[id]."</td><td> ".$data[firstname].
	"</td><td> ".$data[lastname]."</td><td>".$data[email].
	"</td><td> ".$data[username]."</td><td>";
?> 
	<a href="delete/id/<?php echo $data[id];?>">Delete</a></td>
	<td><a href="edit/id/<?php echo $data[id];?>">Edit</a></td>
<?php 
}
?>
<tr><td><a href="index">Registration</a></td></tr>
</table>
</div>                                    

< mega store Login form in zend framework 1 >



Ask a question



  • Question:
    {{questionlistdata.blog_question_description}}
    • Answer:
      {{answer.blog_answer_description  }}
    Replay to Question


Back to Top