Forum Moderators: coopster

Message Too Old, No Replies

help with query please

         

hanyaz

1:56 pm on Jul 9, 2009 (gmt 0)

10+ Year Member



Hello,
I have the following query giving me umpty results, why ? It is even the case when the variable $region is present in the url

$region=$_GET['region']; //from url
$query = "SELECT a.*, p.name as parent, p.id as parentid, c.name as cat, c.id as catid, $name as user
FROM #__adsmanager_ads as a
LEFT JOIN #__adsmanager_adcat as adcat ON adcat.adid = a.id
LEFT JOIN #__users as u ON a.userid = u.id
LEFT JOIN #__adsmanager_categories as c ON adcat.catid = c.id
LEFT JOIN #__adsmanager_categories as p ON c.parent = p.id
WHERE $search and c.published = 1";

if (isset($region)) {
$query.= "and a.ad_region ='$region'";
}
$query.="GROUP BY a.id ORDER BY $order_text";

thanks in advance

andrewsmd

2:27 pm on Jul 9, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's hard to tell without your table structure. Also, I would recommend not using as. I know it can abbreviate things, but it makes debugging harder because there is more to read and check. Just take the time and write out the full table name.full column name. I would try
WHERE $search = '1' and c.published = '1'";