Welcome Guest, Not a member yet? Register   Sign In
Database Query not displaying expected output.
#2

[eluser]Sumon[/eluser]
You miss increment the counter $count for inner for loop.

Try to use this one
Code:
foreach($query->result() as $row)
        {
            $array[$count]['id'] = $row->id;
            $array[$count]['name'] = $row->name;
            
            $this->db->where('parent', $row->id);
            $newquery = $this->db->get('categories');
            if ($newquery->num_rows() > 0)
            {
                foreach($newquery->result() as $newrow)
                {
                    $count++;
                    $array[$count]['id'] = $newrow->id;
                    $array[$count]['name'] = '  - ' . $newrow->name;
                }
            }
            
            $count++;
        }


Messages In This Thread
Database Query not displaying expected output. - by El Forum - 09-30-2008, 10:11 AM
Database Query not displaying expected output. - by El Forum - 09-30-2008, 01:41 PM



Theme © iAndrew 2016 - Forum software by © MyBB