基于MYSQL值突出显示PHP某种颜色的单元格

我有三个值可以显示mysql,RED,GREEN,YELLOW中的表/列中,用于字段“ProspectStatus”

反正我是否可以根据值改变背景颜色?

例如

echo "<td>" . $row['ProspectStatus'] . "</td>";

PHP代码

 $result = MysqL_query("SELECT * FROM customerdetails"); 
//List the Columns for the Report 
echo "<table border='1'> 
<tr> 
<th>CustomerID</th> 
<th>Customer Name</th> 
<th>Prospect Status</th> 
<th>Address</th> 
</tr>"; 

while($row = MysqL_fetch_array($result)) 
  { 
  echo "<tr>"; 
  echo "<td>" . $row['CustomerID'] . "</td>"; 
  echo "<td>" . $row['CustomerName'] . "</td>"; 
  echo "<td>" . $row['ProspectStatus'] . "</td>"; //this is the field I want to show either RED, GREEN or YELLOW 
  echo "<td>" . $row['Address'] . "</td>"; 
  echo "</tr>"; 
  } 
echo "</table>";  

解决方法:

你可以这样做:

while($row = MysqL_fetch_array($result)) 
  { 
  echo "<tr>"; 
  echo "<td>" . $row['CustomerID'] . "</td>"; 
  echo "<td>" . $row['CustomerName'] . "</td>"; 
  if($row['ProspectStatus']=='[val1]') // [val1] can be 'approved'
         echo "<td style='background-color: #00FF00;'>".$row['ProspectStatus']."</td>"; 
  else if($row['ProspectStatus']=='[val2]')// [val2]can be 'rejected'
         echo "<td style='background-color: #FF0000;'>".$row['ProspectStatus']."</td>"; 
  else if($row['ProspectStatus']=='[val3]') //[val3] can be 'on hold'
         echo "<td style='background-color: #FFFF00;'>".$row['ProspectStatus']."</td>"; 
  echo "<td>" . $row['Address'] . "</td>"; 
  echo "</tr>"; 
  } 
echo "</table>";  

状态的值可能取决于颜色.我假设val1,val2和val3是3种颜色的值.

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...