public9nf
public9nf

Reputation: 1399

Joomla query - Select from content where state is published

I need to show all published joomla articles with the category id = 43. My query:

<?php
    $catId = 43;
    $state = 1;
    $query = "SELECT * FROM #__content WHERE catid ='" . $catId . "' order by title asc";
    $db = JFactory::getDBO();
    $db->setQuery($query); 
    $articles = $db->loadObjectList(); 
    foreach($articles as $article) {
        echo 'Content';
    }
?>

Upvotes: 2

Views: 828

Answers (1)

Yoleth
Yoleth

Reputation: 1272

Add state condition :

 $query = "SELECT * FROM #__content WHERE catid ='" . $catId . "' and state = 1 order by title asc";

Upvotes: 2

Related Questions