[eluser]brandingdavid[/eluser]
Okay, so it was your $this->db->where statement that wasn't working.
Changed to = $this->db->where('parent', $results[$x]['id']);
Tried this for my model:
Code:
<?php
class Category extends Model {
// Constructor
function __construct () {
parent::Model();
}
function get_all ($parent=0) {
$this->db->where('parent', $parent);
$query = $this->db->get('bin_location');
$parents = $query->result_array();
$results = array ();
//print_r($parents);
$x = 0;
foreach ($parents as $parent) {
$results[$x] = $parent;
//echo $results[$x]['id'];
$this->db->where('parent', $results[$x]['id']);
$query = $this->db->get('bin_location');
$results[$x]['children'] = $query->result_array();
print_r ($results[$x]['children']);
$x++;
}
//print_r($results[$x]);
}
// print_r($results);
}
Got me part of the way there... already though I can see that it doesn't come back and do the third level. The children of children. Also, I can't get it to display. I get:
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: views/frontpage_view.php
Line Number: 12
CODE USED: foreach ($categories as $category) {