我添加了行t.cover='$c'
,现在它不会显示任何结果。但是,所有变量都是正确的。如果我在phpMyAdmin中运行该行,它将显示结果正常。我在PHP中缺少语法吗?如果我删除t.cover='$c'
脚本在网络上正常工作。 $c
只是一个$_GET['c']
,它将为空或等于0,我将其重新定义为“否”。
if($t != '') {
if($c == 'No') {
$getListings = mysql_query("SELECT * FROM events t LEFT JOIN bars b on t.venue=b.name WHERE t.date='$date' AND t.type='$t' AND t.cover='$c' AND b.active='1' ORDER BY t.promoted DESC, t.order ASC");
} else {
$getListings = mysql_query("SELECT * FROM events t LEFT JOIN bars b on t.venue=b.name WHERE t.date='$date' AND t.type='$t' AND b.active='1' ORDER BY t.promoted DESC, t.order ASC");
}
} else {
if($c == 'No') {
$getListings = mysql_query("SELECT * FROM events t LEFT JOIN bars b on t.venue=b.name WHERE t.date='$date' AND t.cover='$c' AND t.type='$t' AND b.active='1' ORDER BY t.promoted DESC, t.order ASC");
} else {
$getListings = mysql_query("SELECT * FROM events t LEFT JOIN bars b on t.venue=b.name WHERE t.date='$date' AND b.active='1' ORDER BY t.promoted DESC, t.order ASC");
}
}
我最大的困惑是它在phpMyAdmin中运行但在网络上没有显示任何行的原因。
似乎我在Google上尝试了一切,但仍然没有运气。我希望它会抛出一个错误或某些东西指向我的方向,但它只是出现,好像查询是空的。如果有人有任何想法,我仍然在寻找输入。也许LEFT JOIN正在这样做?
答案 0 :(得分:1)
... LEFT JOIN bars b on t.venue=b.name AND b.active=1
...
从WHERE中删除b.active,否则它将成为SELECT
当前查询具有SELECT... WHERE ... b.active = 1 ...
,这意味着它只能返回满足该条件的结果