我有一个收集客户信息的基本网站。我拥有的数据表具有状态列(已批准,待定)。我想在数据库中显示的状态值上显示彩色标签。
<table cellspacing="0" width="100%" id="example" class="table table-striped table-hover table-responsive">
<thead>
<tr>
<th> ID</th>
<th>Name</th>
<th>Location</th>
<th>Status</th>
</tr>
<tr>
<td><?php echo $row['call_id']; ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['city'] . ', ' .$row['state']; ?></td>
<td><?php echo $row['status']; ?></td>
如果状态(这是一个选项列表)被批准,则表单提交时值= 1 在数据表中,我希望它像一个绿色的盒子,表示已批准。 我很抱歉这是我的第一个网站。
答案 0 :(得分:0)
尝试类似:
<?php if ($row['status'] == 1) { ?>
<td class="green"><?php echo $row['status']; ?></td>
<?php } else { ?>
<td class="otherColor"><?php echo $row['status']; ?></td>
<?php } ?>
和你的css:
.green { background-color: green; }
.otherColor { background-color: /*some other color you want */; }