I'm trying to write a query but it doesn't quite seem to be working properly. Could someone please take a fresh look at it.
$sql = "SELECT
t1.id, t1.product, t1.issue,
t2.id, t2.pub, t2.volume, t2.number,
t3.id, t3.name
FROM t1
LEFT JOIN t2 ON (t1.issue = t2.id)
LEFT JOIN t3 ON ( t2.pub = t3.id )
WHERE t1.onlinestatus = 'ON' ";
$sql .=($thisIssue != 'onlyThisIssue') ? NULL : " AND t1.issue = '".$iID."'";
$sql .= empty($_POST['q']) ? NULL : " AND t1.product LIKE '%".$_POST['q']."%'
OR t1.desc LIKE '%".$_POST['q']."%'
OR t1.ads_legal LIKE '%".$_POST['q']."%'";
if($search = $db->get_results($sql)) {
...
}