0

我如何突出显示员工表行,通过selected_val ==1从表中获取selected_candidate,我只想突出显示表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++;

                                }
                                }
                                ?>
4

1 回答 1

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存在,即是否突出显示。

旁注:您的表格以这种方式未标准化。您可以将other_works 列移动到一个新表中,并将外键 empid 指向该列。

于 2013-01-11T11:30:46.090 回答