How to select and loop through a recordset is shown below. Wht a results, and a loop option:

$jn_select="*";
$jn_from="from_table";
$jn_where="state = 1";
$jn_orderby="id asc";

$db = Factory::getDBO();
$query = $db->getQuery(true)
-> select($jn_select)
-> from($db->quoteName($jn_from))
-> where($jn_where)
-> order ($jn_orderby);
if ($jn_setlimit){
$query->setLimit($jn_setlimit); // max can be set
}
$db->setQuery($query);
$results = $db->loadObjectList();
 
foreach ($results as $item) {
echo $item->column_name
}
 
Happy coding!

Share this page