I added the line AND t.cover='$c'
and now it will not show any results. However, all variables are correct. If I run the line in phpMyAdmin it will display the results fine. Am I missing syntax in PHP? If I remove the t.cover='$c'
the script works fine on the web. $c
is simply a $_GET['c']
that will either be empty or will equal 0, which I redefine to 'No'.
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");
}
}
My biggest confusion is why it works in phpMyAdmin but yet displays no rows on the web.
It seems I have tried everything on Google and still no luck. I wish it would throw an error or something to point me in a direction, but it just comes up as though the query was empty. If anyone has any idea, I am still looking for input. Maybe LEFT JOIN is doing it?
... LEFT JOIN bars b on t.venue=b.name AND b.active=1
...
Remove the b.active from the WHERE otherwise it will be a condition for the SELECT
The current queries have SELECT... WHERE ... b.active = 1 ...
meaning it can only return results where that condition is met
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.