Copy link to clipboard
Copied
I always get confused using " and '. here is my code, where i am trying to echo out an image:
echo "<td>". if($attachment==1) { echo"<img src='http://mysite.com/images/attachment.png' width='20' height='20' />"; } ."</td>";
How do i rewrite this so I no longer get an error?
Copy link to clipboard
Copied
The code looks completely wrong to me. You're concatenating an IF statement that contains an echo within another echo construnct. I'm not very good with PHP syntax, but try:
echo "<td>";
if($attachment==1) {
echo "<img src='http://example.com/images/attachment.png' width='20' height='20' />" };
echo "</td>";
Copy link to clipboard
Copied
close ![]()
if($attachment == 1) {
echo "<img src=
'http://example.com/images/attachment.png
' width='20' height='20' />" ;
}
echo "</td>";
thanks though! ![]()
Copy link to clipboard
Copied
Ah yes, I am always misplacing my semi colons.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now