Premier IT Outsourcing and Support Services within the UK

User Tools

Site Tools

    $db = JFactory::getDbo();
    $query = "SELECT id, title FROM #__content WHERE state=1 AND created > CURDATE()-1;";
    $rows = $db->loadObjectList();
    foreach($rows as $row) {
    	echo "ID:".$id." [".$title."] -> ".$url."<br>";

So in the snippet above we can see that we get all the articles from your Joomla site that were created yesterday onwards. You can change CURDATE()-1 to be just CURDATE() to get articles created today, or indeed change this to be something like (created >= CURDATE()-7 AND created < CURDATE()-1) to get a 6 day window and so on.

Once you have the query results, you can simply extract them as shown in the foreach loop. We only select id and title, but you can of course select anything you wish and access it as $row→field.

/home/ · Last modified: 2019/05/20 10:15 by genadmin