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

Hey sorry if this question is asked before me. I am new to CodeIgniter and want to know what condition is going to be used here so that it display that particular emp_id data. In my code it display data using user_id i want user_id display on the url but form display according to emp_id it display all emp_id data of that user_id
need help

Controller code:

   $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);

view code

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

I think you are mistaking in the query, thats why you get all the rows of the table instead of that only one user.

Use this code:

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