我正在使用一个CodeIgniter
. 我在控制器中的数组中获得了价值,但没有进入视野。我正在使用此控制器从数据库中获取国家/地区,并且在查看页面上我想在分页中显示这些国家/地区。
控制器
public function admin($Username = NULL, $arr = NULL){
if($this->session->userdata('is_log_in')){
$this->load->model('User');
$Username = $this->session->userdata('Username');
$form_data['results'] = $this->User->view_table($Username);
$arr = array();
$arr[]= $this->countries();
$arr[] = $form_data;
echo "<pre>";
print_r($arr); // getting all value here
$this->load->view('templates/header');
$this->load->view('User/User_admin', $arr);
$this->load->view('templates/footer');
}else{
$form_data['msg'] = "Your Can't access this account";
$this->index($form_data);
}
}
看法
if(isset($arr)){
if ($arr->num_rows() > 0){
print_r($arr);
}};
更新
上面的问题就解决了。
现在更新的问题是如何提取这些数组 stdClass 对象
Array
(
[0] => Array
(
[0] => stdClass Object
(
[ccode] => AF
[country] => Afghanistan
)
[1] => stdClass Object
(
[ccode] => AX
[country] => Ã…land Islands
)
[2] => stdClass Object
(
[ccode] => AL
[country] => Albania
)
)
[1] => Array
(
[results] => Array
(
[0] => stdClass Object
(
[id] => 7
[Username] => sachin
[First_name] => shagun
[Last_name] => sood
[Email] => sachin87@gmail.com
[Password] => 202cb962ac59075b964b07152d234b70
[Conf_password] => 123
[Status] => 0
)
)
)
)