I am new to zend framewrok. I am trying to show an image from index view. Below is my code:
<?php
echo "Student List";
//$this->headTitle($this->title);
?>
<p><a href="<?php echo $this->url(array('controller'=>'index',
'action'=>'add'));?>">Add new student</a></p>
<table>
<tr>
<th>Name</th>
<th>Email</th>
<th>Photo</th>
<th> </th>
</tr>
<?php foreach($this->students as $student) : ?>
<tr>
<td><?php echo $this->escape($student->name);?></td>
<td><?php echo $this->escape($student->email);?></td>
<td><img src='opt/lampp/htdocs/framework/zf-tutorial/project.png' alt='sdfsd'></td>
<td>
<a href="<?php echo $this->url(array('controller'=>'index',
'action'=>'edit', 'id'=>$student->id));?>">Edit</a>
<a href="<?php echo $this->url(array('controller'=>'index',
'action'=>'delete', 'id'=>$student->id));?>">Delete</a>
</td>
</tr>
<?php endforeach; ?>
</table>
It only show the alt text not the image. Please help me.
If you use the default folder structure try this:
Create an Folder images
. Put your image project.png
inside of you public
folder (public/images/project.png).
In your view Script use the baseUrl Viewhelper:
<img src="<?php echo $this->baseUrl() . '/images/project.png' ?>" alt='sdfsd'/>