Welcome Guest, Not a member yet? Register   Sign In
Calling img src and alt from database
#1

Hi Everyone,

I've just started using CodeIgniter and have been enjoying it so far.

I have set a view up which is calling content from a database table and everything displays as expected for the text content.

However, I can't find a way to pass the img src and the alt description from the database table (image src in one column and alt in a separate column).

I can display images by calling the image direct from the /assets/images folder prefixed with "echo base_url" so I know it is the string I'm getting wrong.

I've tried searching the forum to no avail and Google examples haven't worked.

The view I have is:

Code:
<h2><?php echo $title; ?></h2>

<?php foreach ($accessories as $accessories_item): ?>

<div class="row" style="border: 1px solid #ccc; padding-top: 5px; margin-bottom: 10px;">
   <div class="col-md-3">
       <img src="<?php echo base_url('assets/images/061.jpg'); ?>" alt="MTH-061" />/* This is where I'm stuck*/
   </div>
   
   <div class="col-md-6">
       <h4><?php echo $accessories_item['title']; ?></h4>
       <p><?php echo $accessories_item['description']; ?></p>
       <p><?php echo $accessories_item['subdescription']; ?></p>
       <p><strong><p><?php echo $accessories_item['subnote']; ?></p></strong></p>
   </div>
   
   <div class="col-md-3 text-right">
       <p>£ <?php echo $accessories_item['price']; ?></p>
   </div>

</div>

<?php endforeach; ?>

Any help, guidance or link to a help resource would be greatly appreciated...

My apologies if this has already been covered as it seems so simple!

Thank you in advance,

Best regards,

Alan
Reply


Messages In This Thread
Calling img src and alt from database - by alann - 10-16-2017, 02:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB