I am fetching data in array and its get data when I use print_r function but when I display the array its said undefined data field.
any way to display result array();? I don’t want to use a foreach loop.
The code is:
$menu2=$this->load->common_model->getRecord('*','inner_menu','menu_page',2);
if ( $menu2->num_rows() > 0) {
$page1 = $menu2->result_array();
print_r($page1);
<?=$page1['url']?>// here it said undeifned variable url
// url is in my db tabel inner_menu
}
Your syntax is really off, or you’re using CodeIgniter in a really strange or unacceptable way.
First, you should be loading your models like this:
Your
getRecord()method should be one that throwsresult_array()to the controller and not the controller calling upon it.Second, in order to get a better understanding, we would need to see some sample code of
getRecord()for us to help you.