Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] How to access my 'data' variable in the view when it contains a DB result I do NOT want to 'foreach loop' throu
#3

[eluser]boltsabre[/eluser]
I love you, you are a genius!

Now my controller looks like (pretty sweet and simple):
Code:
function index(){
        $this->load->model('travel_insurance_model');
        $data['starsAndReview'] = $this->travel_insurance_model->getStarsAndReviewCounts();

        $this->load->view('australian-travel-insurance-view', $data);        
    }

And in the view
(Load a particular travel insurance company using ->row())
Code:
<?php $globe = $starsAndReview->row(2); ?>

(load its image path, where imagePath() is pre-defined elsewhere in my application)
Code:
<img src="....insert code below...."/>
Code:
&lt;?php echo imagePath().$globe->imageNameSmall ?&gt;

Update: Seems you cannot mix html and php syntax here in the forum, my line above was missing half of the echo statement with I had both languages combined and I had to break it into 2 code snippets.

Thanks a million, so very simple (as I knew it would be)!!!


Messages In This Thread
[SOLVED] How to access my 'data' variable in the view when it contains a DB result I do NOT want to 'foreach loop' throu - by El Forum - 06-21-2011, 04:19 PM



Theme © iAndrew 2016 - Forum software by © MyBB