Hi there everyone,
I've tried to cobble together a query using a JOIN, so I can get the parent category id. The problem I've run into is that both the ad and category table have an "id" field. When I grab the value for id, I'm getting the category id, when what I'm hoping for is the ad id.
$sql="SELECT a.id, a.cat_id, a.title, c.id, c.parent FROM classifieds_ads a INNER JOIN classifieds_categories c ON a.cat_id = c.id WHERE parent = 1 AND active = 1 AND end_date > NOW() ORDER BY start_date DESC LIMIT 10";;
$result1=mysql_query($sql) or die (mysql_error());
$numr=mysql_num_rows($result1);
if($numr>0){
while($rows=mysql_fetch_array($result1)){
$id=$rows['id'];
}
}
What should I do to get $id to have the a.id value and not the c.id value?(I tried $id=$rows['a.id'], but that didn't work)?
thanks,
json