Welcome Guest, Not a member yet? Register   Sign In
help for img src
#1

[eluser]sniperscope[/eluser]
Hello
I am very new about Codeigniterand learning it about 2 hours by now but i am developing web sites using php about 9 years.
I wan to know that how can i display img in codeigniter.

my code and my folder hierarchy is below

top/index.php
news/ all images in here about news

So i call it like;
Code:
if(isset($news))
     {
      foreach($news as $news)
      {
       if($news['news_pic'] != "")
       {
        $img_property = array(
          'src' => 'news/' .$news['news_pic'],
          'alt' => $news['news_title'],
          'width' => '240',
          'height' => '320'
         );
         $news_pic = img($img_property);
       }
       else
        $news_pic = '';
       echo '
       <li><table class="ibox">
        <tr><td class="photo">' .$news_pic. '</td>
        <td class="iText"><h3 class="title">' .$news['news_title']. '</h3>
         <p class="time">' .date("Y-n-d", $news['news_date']). '</p>' .nl2br($news['news_body']). '</td>
       </tr>
      </table>';
      }
     }
so, what i want is to display img tag as follow
<img src="../news/img_name.jpg" alt="some_alt" height="320" width="240" />

Seems i stuck here.

Appreciate for any help.
#2

[eluser]amatotax[/eluser]
Whats doing yor img() funct?

Better is:
Code:
&lt;?php
echo '<img src="'.$img_property['src'].'" alt="'.$img_property['alt'].'">';

or

Code:
<img src="&lt;?=img_property['src'];?&gt;" alt="&lt;?=img_property['alt'];?&gt;">
#3

[eluser]sniperscope[/eluser]
Hello
amatotax thanks for reply.
What is output is :
<img src="http://localhost/test_site/news/50c87d149e813.jpg" alt="this is alt tag" width="240" height="320"/>

If i run site without CI then everything run perfect because image directory is correct. But i think CI is searching Controller instead of image itself.




Theme © iAndrew 2016 - Forum software by © MyBB