0

from print_r

Array (
    [0] => stdClass Object (
        [id] => 2729
        [title] =>
        [image_file] => M6_Black_Back.jpg
        [product] => 2
        [active] => 0
        [created] => 2013-06-19 23:14:51
        [rank] => 1
        [publish] => 0
        [back_photo] => M6_Black_Back.jpg
    )
)

this is in my controller

$data['back'] = $this->global_model->custom_query('
        SELECT *,image_file AS back_photo FROM system_product_photos
        WHERE product = 2 AND rank = 1
        ');

$this->load->view('template', $data);

I can't for the life of me get <?=$back->back_photo?> to output anything. Warning codeignighter rookie alert!

1
  • Try $back['back'][0]->back_photo Commented Jun 20, 2013 at 15:13

1 Answer 1

1

$back, in your view, is an array. You're going to need to access the specific item by index <?=$back[0]->back_photo?>, or change the signature of custom_query to only return one item.

Sign up to request clarification or add additional context in comments.

1 Comment

+1, but I just noticed, he loads $data in the template, so shouldn't it be $back['back'][0]->back_photo?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.