Welcome Guest, Not a member yet? Register   Sign In
Forum Help
#1

[eluser]mStreet[/eluser]
Hello!

I'm quite new to OOP as well as Codeigniter, so please bare with me.
Currently I'm just fooling around to just try and get a hang of it all. So I'm building a forum at the moment.

I got stuck on the categories, so I searched all over the place hoping to find a solution, which I did (almost). Then I got stuck trying to print it all out.

I got everything ready and the var dump looks like this:

Vardump IMAGE

It looks exactly like it should but I just can't manage to echo it out correctly.

Here's the controller:

Code:
function categories($parent = NULL) {
        $items = array();
        
        $this->db->where('parent_id', $parent);
        $query = $this->db->get('categories');
        $results = $query->result();
        
        foreach($results as $result) {
            $child_array = Forum::categories($result->id);
            if(sizeof($child_array) == 0) {
                array_push($items, $result->name);
            } else {
                array_push($items, array($result->name, $child_array));
            }
        }
        
        return $items;
    }


Thanks!
#2

[eluser]cbwd[/eluser]
I'd suggest a less complex project for your first attempt at CI/OOP. There's a lot to think about with developing a forum. Might be better to do a few simple CRUD forms to get the hang of things first.

For starters, have a look into how MVC should work, http://ellislab.com/codeigniter/user-gui...w/mvc.html

First thing is getting the db interaction out of the controller and into a model.

How do you want the output to look?

What does it look like at the moment?




Theme © iAndrew 2016 - Forum software by © MyBB