根据CodeIgniter中的emp_id显示数据有问题

时间:2016-08-23 10:03:56

标签: php codeigniter

如果在我面前问这个问题,我很抱歉。我是CodeIgniter的新手,想知道这里将使用什么条件,以便显示特定的emp_id数据。在我的代码中,它使用user_id显示数据,我想在网址上显示user_id,但根据emp_id显示表单,显示emp_id <的所有user_id数据登记/> 需要帮助

控制器代码:

   $q="Select emp_id ,month from employee where user_id= $emp_id and year =".date("Y");
                $details = $this->data['details'] = $this->evaluation_model->q($q);
                //echo"<pre>";print_r($details);die;

                $q ='select distinct section_permissions.assigned_for ,section_id , employee.emp_id ,employee.user_id, employee.month from employee join section_permissions on (section_permissions.assigned_for = employee.user_id) where section_permissions.user_id = '.$user_id;
                $assigned_name = $this->data['assigned_name'] = $this->evaluation_model->q($q);

查看代码

<?php foreach($assigned_name  as $assigned){ ?>
<?php foreach($details as $detail){?>
<?php if($assigned['emp_id'] == $detail['emp_id']){?>

1 个答案:

答案 0 :(得分:1)

我认为你在查询中有误,这就是为什么你得到表的所有行而不是只有一个用户。

使用此代码:

$dat = date("Y"); 
$q = "Select emp_id, month from employee where user_id = '$emp_id' and year = '$dat=date' ";