<td><?php echo "<a href=\"".$row['link']."\" target=\"_self\">Link</a>"; ?></td>
我想链接是超链接仅如果在MySQL表显示在MySQL没有链接的空数据和PHP
任何想法数据[“链接”]?
<td><?php echo "<a href=\"".$row['link']."\" target=\"_self\">Link</a>"; ?></td>
我想链接是超链接仅如果在MySQL表显示在MySQL没有链接的空数据和PHP
任何想法数据[“链接”]?
<?php
if(isset($row['link']) && !empty($row['link']))
{
echo '<td><a href="'.$row['link'].'" target="_self\">Link</a></td>';
} else {
echo '<td>Link</td>';
}
?>
不知道你的表的结构,这是不能说这是否会工作,但它是一个良好的开端:
<?php if(strlen($row['link']) > 0):?>
<td><?php echo "<a href=\"".$row['link']."\" target=\"_self\">Link</a>"; ?></td>
<?php endif; ?>
做一个isset和修剪+ strlen的检查0周围的数据,然后将链接标题包装在锚标签中。
$linkHtml = "Bloopdie";
// Add anchor tag only if there is data in the row
if (isset($row['data']) && strlen(trim($row['data'])) > 0) {
$linkHtml = '<a href="' . $row['data'] . '">' . $linkHtml . '</a>';
}
echo $linkHtml
是啊,但现在有一个问题,我还需要文字链接到显示不完全去除。这个想法就是当数据超链接被创建时,如果不仅仅是正常的文本链接将被显示 – buni
@ user12345678只是添加一个'else'子句,你很好去? – Nasreddine