sunnysideup Posted April 23, 2010 Share Posted April 23, 2010 I'm having issues echoing image in the below code: <?php echo "<span style=\""; # If we gained print the percentage in GREEN if ($data[1]>0) { echo "color: #009900;"; echo "<img src='images/up.png'>"; } # if we lost RED elseif ($data[1]<0) { echo "color: #DF0D0D;"; echo "<img src='images/down.png'>"; } # No color else { echo "font-weight: normal;"; } echo "\">".$data[0]."</span></li>\n"; ?> Can someone please tell me, where i'm going wrong? Quote Link to comment https://forums.phpfreaks.com/topic/199506-cant-echo-an-image/ Share on other sites More sharing options...
calmchess Posted April 23, 2010 Share Posted April 23, 2010 echo "<img src= '../images/down.png'>"; I believe you need to go out a directory you might also want to get rid of the single quotes because its already a string Quote Link to comment https://forums.phpfreaks.com/topic/199506-cant-echo-an-image/#findComment-1047097 Share on other sites More sharing options...
sunnysideup Posted April 23, 2010 Author Share Posted April 23, 2010 Tried echo "<img src= '../images/down.png'>"; but still cant see the image Quote Link to comment https://forums.phpfreaks.com/topic/199506-cant-echo-an-image/#findComment-1047101 Share on other sites More sharing options...
Alex Posted April 23, 2010 Share Posted April 23, 2010 First check the output to see if it's actually outputting your image. If it is then confirm the path is correct. Quote Link to comment https://forums.phpfreaks.com/topic/199506-cant-echo-an-image/#findComment-1047104 Share on other sites More sharing options...
sunnysideup Posted April 23, 2010 Author Share Posted April 23, 2010 No its not outputting any image, and both the images are in "images" folder. Quote Link to comment https://forums.phpfreaks.com/topic/199506-cant-echo-an-image/#findComment-1047105 Share on other sites More sharing options...
Alex Posted April 23, 2010 Share Posted April 23, 2010 I meant you should check the source of the page to see if <img src= '../images/down.png'> appears. Quote Link to comment https://forums.phpfreaks.com/topic/199506-cant-echo-an-image/#findComment-1047106 Share on other sites More sharing options...
sunnysideup Posted April 23, 2010 Author Share Posted April 23, 2010 The Page source is as follows: <table border="0" width="750" id="table2" cellspacing="0" cellpadding="0"> <tr> <td width="80"><font size="2">Sensex</font></td> <td><font face="Tahoma" size="2"> <span style="color: #009900;<img src= '../images/up.png'>">17694.2</span></li> </font></td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/199506-cant-echo-an-image/#findComment-1047108 Share on other sites More sharing options...
litebearer Posted April 23, 2010 Share Posted April 23, 2010 Need more coffee, but... (or at least you can see what I mean) if ($data[1]>0) { ?> <span style="color: #009900;"><img src="../images/up.png"><?PHP echo $data[0]; ?></span> <?PHP } if ($data[1]<0) { ?> <span style="color: #DF0D0D;"><img src="../images/down.png"><?PHP echo $data[0]; ?></span> <?PHP } if($data[1] == 0) { ?> <span style="font-weight: normal;"><img src="../images/down.png"><?PHP echo $data[0]; ?></span> <?PHP } Quote Link to comment https://forums.phpfreaks.com/topic/199506-cant-echo-an-image/#findComment-1047140 Share on other sites More sharing options...
947740 Posted April 23, 2010 Share Posted April 23, 2010 You forgot to close out your style tags. Quote Link to comment https://forums.phpfreaks.com/topic/199506-cant-echo-an-image/#findComment-1047142 Share on other sites More sharing options...
Pikachu2000 Posted April 23, 2010 Share Posted April 23, 2010 <span<img></span> isnt't valid markup. You need to terminate the opening <span> tag. Quote Link to comment https://forums.phpfreaks.com/topic/199506-cant-echo-an-image/#findComment-1047216 Share on other sites More sharing options...
sunnysideup Posted April 24, 2010 Author Share Posted April 24, 2010 Thank you all, My day is saved Quote Link to comment https://forums.phpfreaks.com/topic/199506-cant-echo-an-image/#findComment-1047526 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.