Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is the code of action
PHP
public function listAction()
   {
       // action body
       $params = array('host'      =>'localhost',
                 'username'  =>'root',
                 'password'  =>'mysql',
                 'dbname'    =>'zf'
                );
             $DB = new Zend_Db_Adapter_Pdo_Mysql($params);
             $DB->setFetchMode(Zend_Db::FETCH_OBJ);
             $sql = "SELECT * FROM user ORDER BY user_name ASC";
             $result = $DB->fetchAssoc($sql);
             $this->view->assign('title','Member List');
             $this->view->assign('description','Below, our members:');
             $this->view->assign('datas',$result);
   }

this is the code for the view
<table border="1">
<tr>
<th>ID</th>
<th>User Name</th>
<th>First Name</th>
<th>Last Name</th>
<th>Action</th>
</tr>
<? $datas = $this->datas;
for($i = 1; $i<= count($datas);$i++){ ?>
<tr>
<td><?=$datas[$i]['id']?></td>
<td><?=$datas[$i]['user_name']?></td>
<td><?=$datas[$i]['first_name']?></td>
<td><?=$datas[$i]['last_name']?></td>
<td>
<a href="edit/id/<?=$datas[$i]['id']?>">Edit</a>
|
<a href="del/id/<?=$datas[$i]['id']?>">Delete</a>
</td>
</tr>
<? } ?>
</table>

this is not working properly
please solve it thanks...
Posted
Updated 25-Feb-14 0:39am
v2
Comments
Kornfeld Eliyahu Peter 25-Feb-14 6:35am    
'not working properly' - there is not too much information in it...can you elaborate?
Vivek_Maruxxxx 25-Feb-14 6:42am    
is it ok now
W Balboos, GHB 25-Feb-14 10:41am    
If I were you I'd look into heredoc syntax: <<<

Your constantly opening/closing php blocks is totally unnecessary. You can use something like:
<?php

$this->datas;
$tablerows = '';
for($i = 1; $i<= count($datas);$i++) {
$tableRows .=<<<theRows
<tr>
<td>{$datas[$i]['id']}</td>
<td>{$datas[$i]['user_name']}</td>
<td>{$datas[$i]['first_name']}</td>
<td>{$datas[$i]['last_name']}</td>
<td>Edit | Delete</td>
</tr>
theRows;
}
?>
[no name] 3-Mar-14 0:42am    
could you describe what the problem is and in which line?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900