<?php
if(isset($row['link']) && !empty($row['link']))
{
echo '<td><a href="'.$row['link'].'" target="_self'">Link name</a></td>';
}
?>
使用此代码从表中删除文本链接名称,但我更喜欢保留文本,但当[' Link ']具有空值
时不链接任何想法?
add…
else {
echo "<td>Link Name</td>";
}
<?php
{
echo '<td>';
if(isset($row['link']) && !empty($row['link']))
echo '<a href="'.$row['link'].'" target="_self'">';
echo 'Link name';
if(isset($row['link']) && !empty($row['link']))
echo '</a>';
echo '</td>';
}
?>
这个逻辑允许您做的不仅仅是输出名称。当然,如果您只需要输出名称,那么更简洁的方法是
下投票
if(isset($row['link']) && !empty($row['link']))
{
echo '<td><a href="'.$row['link'].'" target="_self'">Link name</a></td>';
} else {
echo '<td>Link name</td>';
}