Images on View Page

#1
[eluser]01010011[/eluser]
Hi,

Using CodeIgniter, I am trying to place several images onto my view page as follows

Code:
...
<?php foreach($results_found as $item): ?>
<tr>
    <td>&lt;?php echo base_url();?&gt;images/$item->img.jpg</td>?
    <td>&lt;?php echo $item->title ?&gt;</td>
</tr>
...
but all this displays is the url for the images.

I've stored the names of the images in my database, hence my attempt to use $item->img to get access the name. The images are located in my root directory (htdocs\website_name\images)

Any help would be really appreciated. Thanks in advance

#2
[eluser]danmontgomery[/eluser]
$item->img is outside of php tags...

Code:
<td>&lt;img src="&lt;?php echo base_url().'images/'.$item->img.'.jpg'; ?&gt;"/&gt;</td>

#3
[eluser]01010011[/eluser]
Thanks for your reply.

Unfortunately, all I get is a graphic and the outline of where the picture is supposed to be.
[quote author="noctrum" date="1272414623"]$item->img is outside of php tags...

Code:
<td>&lt;img src="&lt;?php echo base_url().'images/'.$item->img.'.jpg'; ?&gt;"/&gt;</td>
[/quote]

#4
[eluser]danmontgomery[/eluser]
So copy the href tag from the source, past the url in your browser and see if you're getting a codeigniter 404 (codeigniter is routing your images, which indicates a problem with htaccess) or a regular 404 (the path is wrong)

#5
[eluser]pickupman[/eluser]
If you are using the rewrite code from the user guide you need to add an exclusion for your images folder. The user guide code redirects all url's to index.php. Also, you may want to drop the http://.base_url() part for the src attribute. This creates additional http request for the browser to resolve.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.