2016-10-04 59 views
-2

我有一個收集客戶信息的基本網站。我擁有的數據表有一個狀態列(已批准,正在申請中)。我想在它從數據庫獲取的狀態值上顯示一個彩色標籤。基於價值的標籤標籤顏色

<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

這不是一個問題。 – Santi

+0

沒有代碼,沒有愛 – Ghost

+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 */; }