Welcome Guest, Not a member yet? Register   Sign In
Code working in 1.7.2 not working on version 2
#1

[eluser]jonny68[/eluser]
Hi,
i'm building my site categories with database and i tested it on another server with CI version 1.7.2 now i'm trying the same with lastest version and it give some error, i know
php 4 is not accepted anymore so i'd like understand where the problem is..

This is the code:
Code:
if (count($navlist)){
  echo "<ul>";
  foreach ($navlist as $key => $list){
   foreach ($list as $topkey => $toplist){
       echo "<li class='cat'>";
     echo anchor('home/cat/'.$topkey,$toplist['name']); //line 10
     echo "</li>\n";
     if (count($toplist['children'])){                  
      foreach ($toplist['children'] as $subkey => $subname){
       echo "\n<li class='subcat'>";
       echo anchor('home/cat/'.$subkey,$subname);
       echo "</li>";
      }
          }
}
  }
  echo "</ul>\n";
}

What happens is that php tells me: undefinded index name in line 10. but show me
all the menu item with error in between and some link with http// etc..

Well! If somebody help me i'd be glad Smile

Thanks in advance!
#2

[eluser]jonny68[/eluser]
By the way this is the model, watching a print_r($data) something doesn't look clear to me, is the query ok?
Code:
function getCategoriesNav(){
     $data = array();
     $this->db->select('id,name,parentid');
     $this->db->where('status', 'active');
     $this->db->order_by('parentid','asc');
     $this->db->order_by('name','asc');
     $this->db->group_by('parentid,id');
     $Q = $this->db->get('categories');
     if ($Q->num_rows() > 0){
       foreach ($Q->result() as $row){
   if ($row->parentid > 0){
    $data[0][$row->parentid]['children'][$row->id]['name'] = $row->name;
                                
   }else{
    $data[0][$row->id]['name'] = $row->name;
   }
  }
    }
    $Q->free_result();
  
    return $data;
    
}
#3

[eluser]InsiteFX[/eluser]
Did you read the change logs for the different CI versions since v1.7.2 ?
#4

[eluser]jonny68[/eluser]
Thanks,

anyway that's seamed not to be the problem..

Sorry.
#5

[eluser]InsiteFX[/eluser]
Try:
Code:
$toplist->name

Also do a var_dump to see what you are getting!




Theme © iAndrew 2016 - Forum software by © MyBB