Displaying data from mutliple arrays with codeigniter

Posted by Craig Ward on Stack Overflow See other posts from Stack Overflow or by Craig Ward
Published on 2010-06-08T12:56:43Z Indexed on 2010/06/08 13:02 UTC
Read the original article Hit count: 233

Filed under:
|
|
|

I am trying to display results from a database where the results are contained in three tables. How do I echo out the results?

$p-> works, but $img-> or $branch-> doesn't. What am I doing wrong?

Example code is below

Sample controller:

$p_id = $this->uri->segment(3);

$this->load->model('One_model');
$data['prop'] = $this->One_model->get_details($p_id);
$data['img'] = $this->One->get_images($p_id);

$this->load->model('Two_model');
$data['branch'] = $this->Two_model->get_details($p_id);

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

A Sample View

<?php foreach ($property as $p):?>
<p><?php echo $p->SUMMARY; ?></p>
<p>We have <?php echo "$img->num_photos"; ?> photos</p>
<p>Branch is <?php echo $branch->name; ?>. Telephone <?php echo $branch->tel; ?></p>
<ul>
<li><?php echo $p->FEATURE1; ?></li>
<li><?php echo $p->FEATURE2; ?></li>
<li><?php echo $p->FEATURE3; ?></li>
<li><?php echo $p->FEATURE4; ?></li>
<li><?php echo $p->FEATURE5; ?></li>
<li><?php echo $p->FEATURE6; ?></li>
<li><?php echo $p->FEATURE7; ?></li>
<li><?php echo $p->FEATURE8; ?></li>
<li><?php echo $p->FEATURE9; ?></li>
<li><?php echo $p->FEATURE10; ?></li>
</ul>
<?php endforeach; ?>

© Stack Overflow or respective owner

Related posts about arrays

Related posts about codeigniter