Die Hervorhebung einer Zelle, PHP eine bestimmte Farbe, die basierend auf MYSQL Wert

Ich habe drei Werte, die angezeigt werden können von einer Tabelle/Spalte in mysql, ROT, GRÜN, GELB für den Bereich "ProspectStatus"

Ist es trotzdem kann ich eine Zelle ändern Ihre Hintergrundfarbe basierend auf dem Wert?

z.B.

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

PHP-Code:

 $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>";  
stackoverflow.com/questions/36716586/... kann jemand bitte helfen, wie lösen Sie obiges problem ?

InformationsquelleAutor | 2013-07-04

Schreibe einen Kommentar