• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.