开发者

How to use foreach() in any controller function of Codeigniter

开发者 https://www.devze.com 2022-12-24 06:45 出处:网络
Hey Guys, I’ve stucked with a problem. Can any body help me for….. “How to use foreach() in any controller function of Codeigniter”. Actually, i’ve a piece of codes which are placed in a Controll

Hey Guys, I’ve stucked with a problem. Can any body help me for….. “How to use foreach() in any controller function of Codeigniter”. Actually, i’ve a piece of codes which are placed in a Controller function in whihc i’m using foreach(). Here is the piece of code…..

$this->load->model('board/dboard_members_model');
$data['query4'] = $this->dboard_members_model->extract_login_user_status($ID,$UserID);
     foreach('query4' as $item):
     if($item->UserStatus == 5)
     {
         redirect('dboard/warning开发者_运维知识库_for_blocked_user/'.$item->DboardID.'', 'refresh');
         exit ;
     }
     endforeach;

what i’m doing at here is, i retrieved some information from DB MODEL function [ extract_login_user_status() ]. After this , i’m using “foreach()” in to extract the some data for comparing that with a a default value for making proper redirection to another Controller function.

So, at here my problem i don’t really know how to extract those each & individual data return back from MODEL function. Please, if any body have any idea to handle such situation reply back as soon as possible.


should be:

foreach($data['query4'] as $item):
     if($item->UserStatus == 5)
     {
         redirect('dboard/warning_for_blocked_user/'.$item->DboardID.'', 'refresh');
         exit ;
     }

Regards,
Pedro


Access Array Elements in Controller :

$this->load->model('board/dboard_members_model');
$data['query4'] = $this->dboard_members_model->extract_login_user_status($ID,$UserID);

foreach($data['query4'] as $item)
{
    if($item['UserStatus'] == 5)
    {
         redirect('dboard/warning_for_blocked_user/'.$item['DboardID'].'', 'refresh');
         exit ;
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消