how to show object data in view file - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: how to show object data in view file (/showthread.php?tid=49515) |
how to show object data in view file - El Forum - 02-22-2012 [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() in controller Code: public function envoyer_chaussure() in view file Code: <body> I have Message: Undefined variable: identifiant thanks !! did you know the solution !! I know here it's an object so I use $item->nom how to show object data in view file - El Forum - 02-22-2012 [eluser]CroNiX[/eluser] Since you are only retrieving 1 row (limit 1) in your getId() method, use $row instead of $result. I'm not sure why you are looping over your results and putting them in a new array. It's already an array of objects (or array of arrays if returning data as array). Just return $query->row(); See the manual for generating query results for the explanations. Then, in your envoyer_chaussure() method, you need to do something like: Code: $data['identifiant'] = $this->site_model->getId(); //the array key "identifiant" will now be $identifiant in your view Your view should work then. |