[英]Codeigniter foreach doesn't work
I have this code.compiler doesn't enter in foreach.我有这个代码。编译器没有进入 foreach。 I don't know why?
我不知道为什么? although i write this foreach in other function and works,please any one help me.
虽然我在其他函数中编写了这个 foreach,但请任何人帮助我。
in model在模型中
public function getting_profile_check($u)
{
$this->db->where('login_name', $u);
return $this->db->get('profile_check');
}
and in controller并在控制器中
public function get_profile_check($user)
{
echo"i in get profile check";
$d=$this->login_m->getting_profile_check($user);
$data=array('check_res'=>$d,'first_time'=>"no");
foreach($d->result() as $field)
{
echo"i in for each in get";
$image=$field->image_c;
$view=$field->overview_c;
$certi=$field->certi_c;
$edu=$field->edu_c;
$hopp=$field->hopp_c;
$lang=$field->lang_c;
echo"session".$image." " .$edu;
}
}
Try this尝试这个
In Controller在控制器中
public function get_profile_check($user)
{
echo"i in get profile check";
$d = $this->login_m->getting_profile_check($user);
$data=array('check_res'=>$d,'first_time'=>"no");
foreach($d as $field)
{
echo"i in for each in get";
$image=$field->image_c;
$view=$field->overview_c;
$certi=$field->certi_c;
$edu=$field->edu_c;
$hopp=$field->hopp_c;
$lang=$field->lang_c;
echo"session".$image." " .$edu;
}
}
In Model在模型中
public function getting_profile_check($u)
{
$this->db->select("*");
$this->db->where('login_name', $u);
$query = $this->db->get('profile_check');
$result = $query->result_array();
return $result;
}
do something like this in model:在模型中做这样的事情:
public function getting_profile_check($u)
{
$this->db->select('*')
->from('profile_check')
->where('login_name', $u);
$query = $this->db->get();
if($query->num_rows > 0){
return $query->result_array();
}
}
in controller:在控制器中:
public function get_profile_check($user)
{
echo"i in get profile check";
$d=$this->login_m->getting_profile_check($user);
foreach ($d as $row ) {
echo $row['name_of_table_column'];
}
}
Model模型
public function getting_profile_check($u)
{
$this->db->where('login_name', $u);
return $this->db->get('profile_check')->result();
}
Controller控制器
public function get_profile_check($user)
{
echo"i in get profile check";
$d=$this->login_m->getting_profile_check($user);
foreach ($d as $row )
{
echo $row->name_of_table_column;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.