2013-01-11 72 views
0

我怎麼能突出顯示員工錶行,通過從表selected_candidate獲取selected_val ==1高亮行,我想強調的只是那些行,其selected_val is 1 結構selected_candidate通過讀取數據庫值

eid int(30) 
rid int(30) 
selected_val int(1) 

我正在使用此查詢來顯示錶格上的員工表格

$query = "SELECT eid,ename,lname,ecell,eposition,eemail,ecountry,estate,ecity,prefcities,ca,cs,cwa,completed,persuing,other_work1,other_work2,other_work3,other_work4,other_work5,other_work6,other_work7,other_work8,selected_val"; 
           $query .= "FROM employee INNER JOIN selected_candidate ON employee.eid = selected_candidate.eid"; 
    $query .= "WHERE efamiliar LIKE '%{$company}%' "; 

這PHP代碼

<?php 

           if(isset($_POST['Submit'])) 
           { 

           //$url="down.php?location={$location}&status={$status}&company={$company}&qr={$qr}&flag={$flag}&count={$count}"; 
           $i=0; 
       while($data_set = mysql_fetch_array($result_set)) 
           { 
       $i=0; 
       echo "<div id=\"Message1[$i]\" class=\"box\">"; 
             echo "Country ={$data_set['ecountry']}<br/>"; 
             echo "State = {$data_set['estate']}<br/>"; 
             echo "</div>"; 

           echo "<tr>"; 
       echo "<td><input id=\"select_candi{$i}\" onclick=\"javascript:func(this.id,{$_SESSION['uid']})\" type=\"checkbox\" name=\"check_candi[]\" value=\"{$data_set['eid']}\"/></td>"; 
       echo "<td>{$data_set['ename']}</td>"; 
           echo "<td>{$data_set['lname']}</td>"; 
           echo "<td>{$data_set['ecell']}</td>"; 
           echo "<td>{$data_set['eposition']}</td>"; 
           echo "<td>{$data_set['eemail']}</td>"; 
           if($data_set['ecity']=='') 
             { 
             echo "<td>{$data_set['ecountry']}</td>"; 
             } 
             else 
             { 
             echo "<td onmouseover=\"ShowText('Message1[$i]'); return true;\" onmouseout=\"HideText('Message1[$i]'); return true;\" href=\"javascript:ShowText('Message1')\">{$data_set['ecity']}</td>"; 
             } 

           // echo "<td>{$data_set['ecountry']},{$data_set['estate']},{$data_set['ecity']}</td>"; 
           echo "<td>{$qua}</td>"; 
       echo "<td>{$data_set['other_work1']} {$data_set['other_work2']}{$data_set['other_work3']}{$data_set['other_work4']} {$data_set['other_work5']} {$data_set['other_work6']} {$data_set['other_work7']} {$data_set['other_work8']} {$data_set['other_work9']} {$data_set['other_work10']} 
       {$data_set['other_work1e']} {$data_set['other_work2e']} {$data_set['other_work3e']} {$data_set['other_work4e']} {$data_set['other_work5e']} {$data_set['other_work6e']} {$data_set['other_work7e']} {$data_set['other_work8e']} {$data_set['other_work9e']} {$data_set['other_work10e']} 
       </td>"; 
        echo "<td><a href=\"detailcv.php?id={$data_set['eid']}\" target=\"_blank\"><input style=\" cursor:hand;width:40px\" class=\"button\" name=\"cv\" type=\"button\" value=\"C V\" /></a></td>";    
           echo "</tr>"; 

           $i++; 

           } 
           } 
           ?> 

回答

0

JOIN兩個表,Employeeselected_candidate,像這樣:

SELECT 
    eid, ename, lname, ecell, 
    eposition, eemail, ecountry, estate, 
    ecity, prefcities, ca, cs , 
    cwa, completed, persuing, other_work1, 
    other_work2, other_work3, other_work4, 
    other_work5, other_work6, other_work7, 
    other_work8, 
    selected_val -- <<<<<<<<<<<<<<<< 
FROM employee 
INNER JOIN selected_candidate ON employee.eid = selected_candidate.eid 
WHERE efamiliar LIKE '%{$company}%'; 

,那麼你可以選擇selected_val。稍後,在前端應用程序中使用PHP,您可以測試該值是否爲== 1,即是否突出顯示該值。

附註:您的表格不是normalized。您可以將other_work的列移動到一個新表中,並在該列中使用外鍵empid。

+0

它給我警告'在這一行mysql_fetch_array($ result_set)'沒有得到正確的數據 – raj

+0

@raj - 你能告訴我你得到的異常,你試過的確切的查詢嗎?謝謝 –

+0

我已經編輯上面的查詢,因爲你有建議,這是警告我越來越'警告:mysql_fetch_array():提供的參數不是一個有效的MySQL結果資源' – raj