limessl Posted December 30, 2009 Share Posted December 30, 2009 I have a table in which each line is dependant on an SQL lookup to determine whether the contents of each row should be displayed or not. Here's the code I'm using :- <?php if ($row["3"] != "0.00" ) echo "<img src="images/stories/button01.gif" />";?> Obviously it doen't work, else I'd not be posting on here. I am an absolute novice in coding, having picked up everything so far on a mix of google and pot luck. Sadly, neither of those methods has helped! FWIW, the cell before this one has the same syntax except says - echo "3 Years" and it displays fine. If I omit the PHP the image file displays so it isn't a problem with the URL. Quote Link to comment Share on other sites More sharing options...
trq Posted December 30, 2009 Share Posted December 30, 2009 You need to escape double quotes within a double quoted string. <?php if ($row["3"] != "0.00" ) echo "<img src=\"images/stories/button01.gif\" />";?> Quote Link to comment Share on other sites More sharing options...
Goldeneye Posted December 30, 2009 Share Posted December 30, 2009 I have a table in which each line is dependant on an SQL lookup to determine whether the contents of each row should be displayed or not. Here's the code I'm using :- <?php if ($row["3"] != "0.00" ) echo "<img src="images/stories/button01.gif" />";?> Obviously it doen't work, else I'd not be posting on here. I am an absolute novice in coding, having picked up everything so far on a mix of google and pot luck. Sadly, neither of those methods has helped! FWIW, the cell before this one has the same syntax except says - echo "3 Years" and it displays fine. If I omit the PHP the image file displays so it isn't a problem with the URL. Either that, or use single-quotes for your strings so you don't have to escape double-quotes: <?php if ($row["3"] != "0.00" ) echo '<img src="images/stories/button01.gif" />';?> Quote Link to comment Share on other sites More sharing options...
abazoskib Posted December 31, 2009 Share Posted December 31, 2009 Or do not echo HTML. Break up your PHP blocks. You'll thank yourself later, and the overhead of going in and out of PHP is much less than echoing tons of HTML. Quote Link to comment 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.