Joomla 2.5 SELECT query result in array - Joomla! Forum - community, help and support
code: select all
function getcategorie()
{
$db = jfactory::getdbo();
$query = "select id,title #__categories order title asc";
$db->setquery($query);
return $db->loadobjectlist();
}results in
code: select all
array(8) {
[0]=>
object(stdclass)#165 (2) {
["id"]=>
string(1) "2"
["title"]=>
string(17) "ongecategoriseerd"
}
[1]=>
object(stdclass)#195 (2) {
["id"]=>
string(1) "3"
["title"]=>
string(17) "ongecategoriseerd"
}
}
but how make foreach statement of it? when try foreach following error message
fatal error: cannot use object of type stdclass array in
welcome joomla forum!
what's variable contains $db->loadobjectlist() object?
if it's $result, use print_r($result) see complete object arrays.
maybe use like:
what's variable contains $db->loadobjectlist() object?
if it's $result, use print_r($result) see complete object arrays.
maybe use like:
code: select all
foreach($result $item){
echo $item->id." - ". $item->title."<br>";
}
Comments
Post a Comment