如果数据库中的值是非付费还是0(二进制),如何将颜色更改为红色?

时间:2017-10-01 22:56:52

标签: php html css

如果状态为未付款,我只想更改文本的颜色。

$query = mysql_query("SELECT * FROM bill_record");

while($row = mysql_fetch_array($query)){
      echo $row['bill_id'];
      echo "<p>".$row['status']."</p>"; // Status has a paid and unpaid 
}

2 个答案:

答案 0 :(得分:0)

<?php 

$query = mysql_query("SELECT * FROM bill_record");

while($row = mysql_fetch_array($query)) {

  echo $row['bill_id'];

  if ($row['status'] == 'unpaid') {
    echo "<p style=\"color: red\">".$row['status']."</p>";
  }

}

答案 1 :(得分:0)

我会添加一个else语句或付费值:

if ($row['status'] == 'unpaid') {
    echo "<p style=\"color: red\">".$row['status']."</p>";
} else {
    echo "<p>".$row['status']."</p>";
}