Forms displaying error if no result is found. |
I have this codes like this in my controller. It works fine. But when there is no record found in the database, it display a lot of errors because of $customer[0]->first_name.
$data['bfname'] = array( 'name' => 'bfname', 'id' => 'bfname', 'class' => 'form-control', 'type' => 'text', 'value' => $this->form_validation->set_value('bfname', $customer[0]->first_name), ); I'm thinking of solving it by: if ($customer) { $bfname = $customer[0]->first_name; } else { $bfname = ''; } Then I'll put the $bfname in the value. But is there another way of solving this in CI? |
Messages In This Thread |
Forms displaying error if no result is found. - by mydiskarte - 04-06-2016, 10:53 AM
RE: Forms displaying error if no result is found. - by PaulD - 04-06-2016, 11:07 AM
RE: Forms displaying error if no result is found. - by cartalot - 04-07-2016, 01:24 PM
RE: Forms displaying error if no result is found. - by spjonez - 04-09-2016, 08:03 AM
RE: Forms displaying error if no result is found. - by mydiskarte - 04-11-2016, 09:30 AM
|