if语句-PHP echo-如何在mySQL中未输入URL时不显示按钮


if statement - PHP echo - How to make a button not appear when no URL entered in mySQL?

我希望登录按钮只在输入URL时出现在网站上。按原样,无论是否显示URL,它都会显示。

<a class='button' href='<?php echo $expert['url'];?>'>Sign in</a>

我尝试了不同的方法,但没有任何效果。

<?php if($url==1){?>
<a class='button' href='<?php echo $expert['url'];?>'>Sign in</a>
<?php }?>

我错过了什么?

这似乎是一个简单的解决方案!

试试这个:

<?php
if (empty($expert['url'])) {
echo "No URL";
 } else {
echo "<a class='button' href='$expert['url']'>Sign in</a>";
}
?>

我认为你需要使用的是空的。