• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to show object data in view file

#1
[eluser]ludo31[/eluser]
Hello ;

I would like to show in view files the resultat of this query result

in model (here I would like to show the last line of inserting in the table
Code:
public function getId()
        {
            $this->db->select('id','nom');
            $this->db->from('chaussure');
           $this->db->order_by("id", "desc");
            $this->db->limit(1);
            $query = $this->db->get();
            
              if($query->num_rows()>0)
                       {
                         foreach($query->result()as $row)
                         {
                           $data[] = $row;
                         }
                            
                        
                          return $data ;
                       }
        }

in controller

Code:
public function envoyer_chaussure()
    {
  $identifiant[] =  $this->site_model->getId();
              
              $this->load->view('details',$identifiant);


}

in view file

Code:
<body>
    <h1>Details sur les Chassure</h1>
    
  
        &lt;?php  if($identifiant!=null):
            foreach ($identifiant as $item): ?&gt;
            
             &lt;?php echo $item->nom ; ?&gt;
            
              &lt;?php echo $item->id ; ?&gt;
            
             &lt;?php endforeach; endif; ?&gt;

I have Message: Undefined variable: identifiant

thanks !! did you know the solution !! I know here it's an object so I use $item->nom


Messages In This Thread
how to show object data in view file - by El Forum - 02-22-2012, 12:36 PM
how to show object data in view file - by El Forum - 02-22-2012, 01:29 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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