Displaying news on category basis

162 Views Asked by At

I have created a news module in codeigniter(pyrocms) in which news is added on category basis

i am stucked in retreiving the news detail on the basis of category selected

my query for getting news details from frontend is:-

$result='';
$sql= "SELECT `default_news`.*,IFNULL(default_newscategoriesff.name,'N.A.') As category  FROM (`default_news`) LEFT outer  JOIN `default_newscategories` default_newscategoriesff on  default_newscategoriesff.id=`default_news`.`category` WHERE `default_news`.`active` = '1' ORDER BY `updated_on` DESC ";
$allnews = $this->db->query($sql)->result();    
return $allnews;

what will be the where condition for selecting the news details on category basis means if i click on national category it should display all the news under national category

1

There are 1 best solutions below

3
On

Try this

select a.id, a.name, b.name from default_news as a, default_newscategories as b where a.category=b.id and b.name='national' order by a.id desc;