我试图在行/列中没有y id时隐藏youtube播放器,我尝试但不知道我做错了什么。非常感谢你
include 'config.php';
if (isset($_GET['id'])){
$naamID = mysql_real_escape_string($_GET['nameID']);
$id = mysql_real_escape_string($_GET['id']);
$idnext = $id + 1;
$gn = (" SELECT * FROM category WHERE nameID='".$nameID."'") or die(mysql_error());
$go = (" SELECT * FROM post WHERE id='".$id."' and youtube='".$id."'") or die(mysql_error());
$gnn = mysql_query($gn) or die(mysql_error());
$goo = mysql_query($go) or die(mysql_error());
$gnnn = mysql_fetch_array($gnn);
$gooo = mysql_fetch_array($goo);
// down here is the problem
if(!empty($gooo)){
echo 'no video player';
} else {
echo '<h1> '.$gooo["title"].'</h1><br />';
echo '<iframe width="560" height="315" src="//www.youtube.com/embed/'.$gooo["youtube"].'" frameborder="0" allowfullscreen></iframe><br />';
}
答案 0 :(得分:3)
如果变量为空,则函数empty返回true,因此请删除!。
if(empty($gooo)){
echo 'no video player';
} else {
echo '<h1> '.$gooo["title"].'</h1><br />';
echo '<iframe width="560" height="315" src="//www.youtube.com/embed/'.$gooo["youtube"].'" frameborder="0" allowfullscreen></iframe><br />';
}