March 2, 2012
frustrated db query and getvalue in a view after failure
Question by Pablov Ivanov
After I print out a query of a list of user satisty some condition from my database I have got the following array
Array ([0]=>Array([users]=>Array([id]=>6 [username]=>sam [fullname]=>Sam Ho)))
But when I try to get the value in a view like
someone['fullname']
I have got nothing then
<?php
foreach($users as $row)
{
?>
<h1>His name is <?php echo strtoupper($row['fullname']);?></h1>
<?php
}
?>
Answer by Starx
In your case, the following should work perfectly.
foreach($array as $key => $val) {
echo $val['users']['id'];
// and so on
}
I am assuming $array
as your main array of records.