我有两张桌子:
我有一个排行榜,我正在回应表1 的整体得分值:
问题:我在这里要做的是,无论谁得分" -10"在表2(每周得分)中,我想通过突出显示其排行榜中现在为黄色的方框颜色为红色来提醒用户。
当前的css涉及:
li mark div {
display: block;
margin: 4px;
padding: 5px;
min-height: 50px;
border: 2px solid #eebb55;
border-radius: 7pt;
background: grey;
}
Php参与显示列表。这是为了"整体" (排行榜中的右侧标签)。每周也有相似的内容。
<div id="overalllb" class="leadboardcontent" style="display:none">
<div class="leaderboard">
<ol>
<li>
<mark>
<?php while( $toprow2 = sqlsrv_fetch_array( $stmt3) ) {
echo "<div class='parent-div'><span class='rank'>" . $toprow2['overallRank'] . "</span><span class='name'>" . $toprow2['EmployeeName'] . "</span><span class='points'>" . $toprow2['Total_points_Rewarded'] . "</span></div>";
} ?>
</mark>
</li>
</ol>
</div>
传递查询以从两个表中检索信息:
1.query 1 - 查找得分为-10的所有员工。
$q200 = " select *
from Table2
where WeekNumber = 'week1' and pointsRewarded = '-10';";
$stmt200=sqlsrv_query($conn,$q200);
if($stmt200==false)
{
echo 'error to retrieve info !! <br/>';
die(print_r(sqlsrv_errors(),TRUE));
}
查询2-从表1中检索所有员工:
$q20 = "select *
from EmployeeTable
order by Total_points_Rewarded desc";
$stmt20=sqlsrv_query($conn,$q20);
if($stmt20==false)
{
echo 'error to retrieve info !! <br/>';
die(print_r(sqlsrv_errors(),TRUE));
}
我尝试过的代码:
<?php while( $toprow20 = sqlsrv_fetch_array( $stmt20) ) {
echo "<div class='parent-divv'><span class='rank'>" . $toprow20['overallRank'] . "</span><span class='name'>" . $toprow20['EmployeeName'] . "</span><span class='points'>" . $toprow20['Total_points_Rewarded'] . "</span></div>";
}?>
<?php if ($toprow20['EmployeeID'] == $toprow200['EmployeeID'] ) ?>{
<style>
.parent-divv {
border: 1px solid red;
}
</style>
}
上面的代码将所有颜色都更改为红色。我希望两个查询中只匹配的名称/ ID为红色。保持不变。 我正在使用PHP,请建议我这样做。上帝保佑。
答案 0 :(得分:0)
1)将查询加入一个
select EmployeeTable.*,Table2.pointsRewarded as `weeklyDelta`
from EmployeeTable join Table2 on EmployeeTable.EmployeeID = Table2.EmployeeID
where Table2.WeekNumber = 'week1'
order by Total_points_Rewarded desc
2)然后给负值增量的员工一个特殊的班级
<?php
while( $toprow2 = sqlsrv_fetch_array( $stmt3) ) {
echo "<div class='parent-div" .
($toprow2['weeklyDelta'] <= -10 ? " dropped" : "") .
"'><span class='rank'>" .
$toprow2['overallRank'] . "</span><span class='name'>" .
$toprow2['EmployeeName'] . "</span><span class='points'>" .
$toprow2['Total_points_Rewarded'] . "</span></div>";
} ?>
3)给那些员工一个风格
.parent-div.dropped { color:red }