Welcome Guest, Not a member yet? Register   Sign In
Problem with foreach in Model
#1

[eluser]Shpigford[/eluser]
I've got the following function in a model:
Code:
function getCategories()
    {
        
        $this->db->select('id, name, parent_id');
        $this->db->where('type', 'product');
        $this->db->where('active', 'Y');
        $this->db->where('parent_id', '0');
        
        $query = $this->db->get('categories');
        
        foreach ($query->result() as $category)
        {
            $output .= '<option value="'.$category->id.'">'.$category->name.'</option>';
        }
        
        return $output;
    }
But when I try to use the function I get: "Message: Undefined variable: output"


Messages In This Thread
Problem with foreach in Model - by El Forum - 01-21-2008, 09:59 PM
Problem with foreach in Model - by El Forum - 01-21-2008, 10:10 PM
Problem with foreach in Model - by El Forum - 01-21-2008, 10:13 PM
Problem with foreach in Model - by El Forum - 01-21-2008, 10:32 PM
Problem with foreach in Model - by El Forum - 01-21-2008, 11:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB