我有一个问题,我不确定它是否可能,这是我的带有 mysql 数据的 php 页面
// connect to the database
include("connect-db.php");
$color ="#ffffff";
$color3 ="#99C";
$fontsize ="2";
$color4 ="#6CC";
$id = $rows['id'];
echo "<center><table border='2' cellspacing='0' cellpadding='2' class='sortable' bordercolor='#6699FF' bordercolor='#6699FF' width='100%'>
<tr>
<th >CitizenID</th>
<th>Worked</th>
<th>Military Rank Points</th>
<th>Supply Amount</th>
<th>Supplied</th>
<th>eDay</th>
</tr>";
$results = mysqli_query($con,"SELECT * FROM `supplies` ORDER BY citname ASC, eday ASC");
while($row = mysqli_fetch_array($results))
{
if($row['citname'] <> $current_citizenship){
$current_citizenship = $row['citname'];
echo "<tr>
<td colspan='7' align='center' bgcolor='" . $color4 . "'><strong><a name='" . $row['citname'] . "' id='" . $row['citname'] . "'>" . $row['citname'] . "</a></strong></td>
</tr>";
}
if ($row['wassupplied'] == Yes){
$color9 = "green"; } else
$color9 = "red";
if ($row['worked'] == Yes){
$color8 = "green"; } else
$color8 = "red";
if ($row['supplyamount'] < 11){
$color7 = "green"; } else
$color7 = "red";
if ($row['supplyamount'] == 10){
$color7 = "yellow"; } else
$color7 = "red";
if ($row['supplyamount'] > 20){
$color7 = "#FC0"; }
echo "<tr>";
echo "<td align='center' valign='middle' width='75px' bgcolor='" . $color3 . "'><font size='" . $fontsize . "'><a href='http://www.erepublik.com/en/citizen/profile/" . $row['citid'] . "' target='_blank'>".$row['citid']."</a></td>";
echo "<td align='left' valign='middle' bgcolor='" . $color8 . "'><font size='" . $fontsize . "'>" . $row['worked'] . "</td>";
echo "<td align='left' valign='middle' bgcolor='" . $color6 . "'><font size='" . $fontsize . "'>" . $row['rankpoints'] . "</td>";
echo "<td align='left' valign='middle' bgcolor='" . $color7 . "'><font size='" . $fontsize . "'>" . $row['supplyamount'] . "</td>";
echo "<td align='left' valign='middle' bgcolor='" . $color9 . "'><font size='" . $fontsize . "'>" . $row['wassupplied'] . "</td>";
echo "<td align='left' valign='middle' bgcolor='" . $color . "'><font size='" . $fontsize . "'>" . $row['eday'] . "</td>";
echo "</tr>";
}
mysqli_close($con);
我想设置一个变量,例如我所做的
if ($row['worked'] == Yes){
$color8 = "green"; } else
$color8 = "red";
为了$row['rankpoints']
这是我的问题
我的 mysqli 查询循环按 citname 分组,每个 citname 都有每天显示的排名点
if ($row['rankpoints'] == $row['rankpoints'] ){
$color6 = "red"; } else
$color6 = "grenn";
现在我的问题是我需要它与之前的 eday 字段进行比较,这样如果 2 个 rankpoints = 相同的 $color6 那么那些会变成红色
我希望这是理解
我想做的是以下