Welcome Guest, Not a member yet? Register   Sign In
Problems getting foreach loop to display data
#1

[eluser]douglasbrownca01[/eluser]
I'm getting a Trying to get property of non-object error in my for each statement

My Model:

Code:
public function get_accessories($limit) {


  // BRINGS BACK DATA BY BRAND

  $q = $this->db->select('*')
   ->from('accessories')
   ->where('category','Air Inlet')
            ->limit($limit)
   ->order_by('brand')
   ->order_by('item_code');
  
  // BUILD RESULTS QUERY
  $ret['rows'] = $q->get()->result();

  // Capcitors
  $q = $this->db->select('*')
   ->from('accessories')
   ->where('category','Capacitor')
            ->limit($limit)
   ->order_by('brand')
   ->order_by('item_code');
  
  $ret['capcitors'] = $q->get()->result();
  
  return $ret;

  }

  public function get_fingerguards($limit) {
  $rows = $this->db->select('*')
   ->from('accessories')
   ->where('category','Finger guard')
            ->limit($limit)
   ->order_by('brand')
   ->order_by('item_code');
  
  $new['fingerguards'] = $rows->get()->result();
  
  return $new;

  }



}

My controller

Code:
$results = $this->accessories_model->get_accessories($limit);
  $data['products'] = $results['rows'];
  $data['capcitors'] = $results['capcitors'];
                $data['fingerguards'] = $this->accessories_model->get_fingerguards($limit);


My view


Code:
<?php foreach($fingerguards as $fingerguard):?>
                                          <tr  padding:0;">
                                             <td ><span class="cb-ass" ></span></td>
                                             <td colspan="2"><span class="cb-ass">&lt;?php if($fingerguard->image === 'placeholder.jpg') {echo '<image src="'.base_url().'FS/products/product-image.png">';} else {echo '<image src="'.base_url().'FS/products/'.$fingerguard-&gt;id.'/product-image.png">';} ?&gt;</span></td>
                                             <td align="left"><span class="cb-ass">&lt;?php echo $fingerguard['item_code'] ?&gt;</span> </td>
                                             <td align="left"><span class="cb-ass">&lt;?php echo $fingerguard->brand;?&gt;</span> </td>
                                             <td align="left"><span class="cb-ass">&lt;?php echo $fingerguard->item_description;?&gt;</span> </td>
                                             <td align="left"><span class="cb-ass">&lt;?php echo $fingerguard->fan_type;?&gt;</span></td>

                                         </tr>
                                         &lt;?php endforeach; ?&gt;


The two data sets from the $results variable are working fine and I'm able to display the rows. But not with the fingerguards variable. What I'm I missing?


Messages In This Thread
Problems getting foreach loop to display data - by El Forum - 01-08-2013, 05:28 AM
Problems getting foreach loop to display data - by El Forum - 01-08-2013, 06:19 AM
Problems getting foreach loop to display data - by El Forum - 01-08-2013, 06:27 AM
Problems getting foreach loop to display data - by El Forum - 01-08-2013, 06:49 AM
Problems getting foreach loop to display data - by El Forum - 01-08-2013, 07:05 AM
Problems getting foreach loop to display data - by El Forum - 01-08-2013, 07:29 AM
Problems getting foreach loop to display data - by El Forum - 01-08-2013, 07:39 AM
Problems getting foreach loop to display data - by El Forum - 01-08-2013, 07:53 AM
Problems getting foreach loop to display data - by El Forum - 01-08-2013, 08:03 AM
Problems getting foreach loop to display data - by El Forum - 01-08-2013, 08:16 AM
Problems getting foreach loop to display data - by El Forum - 01-08-2013, 08:28 AM
Problems getting foreach loop to display data - by El Forum - 01-08-2013, 08:28 AM
Problems getting foreach loop to display data - by El Forum - 01-08-2013, 08:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB