Zend Framework-9:
Styling:
In this tutorial we left the styling part of the current project for you, and you can implement the styling part as per your interest and requirement. We will create a folder add a style sheet file(style.css) in public folder css, the name can be select as per your choice.
Listing Books:
Now we will start the displaying part with the help of IndexController class, indexAction() function will display the output as tabular format.
IndexController.php
public function indexAction(){
// action body $this->view->title="My Books"; $this->view->headTitle($this->view->title); $books=new Application_Model_DbTable_Books(); $this->view->books=$books->fetchAll();}
Index.phtml
<p><a href="<?php echo $this->url(array('controller'=>'index','action'
=>'add'));?>">Add new book</a></p><
table><
tr><
th>Title</th><
th>Author</th><
th>Publisher</th><
th> </th></
tr><?php
foreach($this->books as $book) : ?><
tr><
td><?php echo $this->escape($book->title);?></td><
td><?php echo $this->escape($book->author);?></td><
td><?php echo $this->escape($book->publisher);?></td><
td><
a href="<?php echo $this->url(array('controller'=>'index','action'
=>'edit', 'id'=>$book->id));?>">Edit</a><
a href="<?php echo $this->url(array('controller'=>'index','action'
=>'delete', 'id'=>$book->id));?>">Delete</a></
td></
tr><?php
endforeach; ?></
table>