Codeigniter - get only 1 row from table |
I know this is a noob question but atm I can't figure out what i'm doing wrong.
I have model : PHP Code: public function getRow($id, $table) { and in view : PHP Code: <?php echo $data->column_name; ?> This work but if there are no records I get : Trying to get property of non-object .. I can't for the life of me remember how I fix the problem last time ...
Website : www.my-web-projects.com
In your controller add code like this
PHP Code: public function view($id)
(03-20-2015, 03:07 AM)suhindra Wrote: In your controller add code like this That can't help at all .. Since i don't want to display a error page. I need to get records from a row and display then ( ' works' ) and if the return is NULL to display "nothing" at the section where I wanted to display them .. not to give error ...
Website : www.my-web-projects.com
03-20-2015, 04:15 AM
(This post was last modified: 03-20-2015, 04:17 AM by suhindra. Edit Reason: typo ) (03-20-2015, 03:13 AM)GrigoreMihai Wrote: That can't help at all .. Since i don't want to display a error page. I need to get records from a row and display then ( ' works' ) and if the return is NULL to display "nothing" at the section where I wanted to display them .. not to give error ... How about add if(isset()) in your view? PHP Code: <?php
Since you return NULL if none are found, then in your view you'd need to test for that and display a message or something.
PHP Code: <?php if (is_null($data)): ?>
Thanks .... works perfect ... forgot about is_null and isset ....
Website : www.my-web-projects.com
|
Welcome Guest, Not a member yet? Register Sign In |