2016-08-23 87 views
0

如果在我之前詢問了這個問題,很抱歉。我是CodeIgniter的新手,想知道這裏將使用什麼條件,以便它顯示那個特定的數據emp_id。在我的代碼顯示它使用user_id數據我想在URL user_id顯示,但根據emp_id形式顯示它顯示的是user_id
所有emp_id數據需要幫助根據CodeIgniter中的emp_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']){?> 

回答

0

我認爲你錯誤的查詢,這就是爲什麼你得到的所有行的表,而不是噸帽子只有一個用戶。

使用此代碼:

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

thankew :)它爲我工作 – eliana

+0

的歡迎...... –