Reputation: 169
I have a while loop that is going through and displaying an RSS icon for websites from database values. The while loop is working well but right now it is displaying an RSS icon for every site. I only want to display an icon if there is a RSS URL value in the database. Below is what I have coded thus far.
The error message I am receiving is: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'
I believe I have a syntax error but am still learning so apologize if this is basic but I am again still learning. Thank you very much for your help.
<td><div class="centerit"><a href="
<?php if (isset($r['rssURL'])) {
echo $r['rssURL'] target='_blank'><img src='images/rssIcon.gif'></a>;
}
?>"</div></td>
Upvotes: 0
Views: 350
Reputation: 164760
Your PHP code is getting mixed incorrectly with the markup. Try the following
<td>
<div class="centerit">
<?php if (isset($r['rssURL'])) : ?>
<a href="<?php echo $r['rssURL'] ?>" target="_blank">
<img src="images/rssIcon.gif">
</a>
<?php endif ?>
</div>
</td>
Upvotes: 3
Reputation: 254916
echo $r['rssURL'] target='_blank'><img src='images/rssIcon.gif'></a>;
This is invalid. I think you meant something like
<td><div class="centerit"><a href="
<?php if (isset($r['rssURL'])) {
echo $r['rssURL'];
}
?>" target='_blank'><img src='images/rssIcon.gif'></a></div></td>
or even:
<td>
<div class="centerit">
<a href="<?php echo isset($r['rssURL']) ? $r['rssURL'] : ''; ?>" target='_blank'><img src='images/rssIcon.gif'></a>
</div>
</td>
Upvotes: 1