I have an array, that I want to retrieve the values from. When I test the array with a print_r, it says that it has the right values. But when I want to show them in their right places, it says that it has no values.
function employees_items($nodeid, $language)
{
$query = db_query(//SOME QUERY);
$rows = array();
foreach ($query as $row) {
$rows[] = array(
$row->nid,
$row->title,
$row->field_service_nummer_value,
$row->field_support_email_value,
$row->uri,
);
}
return $rows;
}
Here I want to retrieve the values...I want the value in $row->uri. The errormessage: Trying to get property of non-object i employees_block_view()
function employees_block_view($delta = '')
{
if (array_key_exists($brandpage_id_page, $medarbejder_brandpages))
{
switch ($delta)
{
case 'employees':
$employees = employees_items($brandpage_id_page, $lang_name);
foreach ($employees as $row)
{
$block['content'] .= '<div class="img">';
$block['content'] .= '<img style="width: auto; height: 100px;" src="'.file_create_url($row->uri). '" alt="Vores support medarbejder" />';
}
return $block;
}
I found the answer. This is the way it must be written to read the value of 'uri'.
$block['content'] .= '<img style="width: auto; height: 100px;" src="'.file_create_url($row['uri']). '" alt="Vores support medarbejder" />';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.