表行背景颜色跳过行
问题描述:
我有一个PHP代码,用JSON查询加载表上的记录,循环直到读取所有MySQL查询结果。表行背景颜色跳过行
我想添加表格行背景颜色。但它总是只影响其他行。
我对PHP和Java相当陌生。我只通过在网络上进行尝试和研究来学习,并没有任何正式的Java和PHP培训。
下面是代码:
<table id="example" class="table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>ID</th>
<th>Message Type</th>
<th>Crime Type</th>
<th>Description</th>
<th>Date/Time Reported</th>
<th>Date/Time Committed</th>
<th>Sender</th>
<th>Status</th>
<th>Options</th>
</tr>
</thead>
<tfoot>
<tr>
<th>--</th>
<th>--</th>
<th>--</th>
<th>--</th>
<th>--</th>
<th>--</th>
<th>--</th>
<th>--</th>
</tr>
</tfoot>
<tbody>
<?php
$query = "SELECT reports.id, types.`name`, classifications.`name` as class, reports.description,
concat(DATE_FORMAT(reports.committed_at,'%b %e, %Y'), ' at ', TIME_FORMAT(reports.committed_at,'%l:%i:%p')) as committed_at,
concat(DATE_FORMAT(reports.created_at,'%b %e, %Y'), ' at ', TIME_FORMAT(reports.created_at,'%l:%i:%p')) as created_at,
reports.casestat, users.`name` as sender, concat(status.id, ' - ', status.status) as status FROM reports
INNER JOIN types ON reports.type_id = types.id
INNER JOIN classifications ON reports.classification_id = classifications.id
INNER JOIN users ON reports.created_by = users.id
INNER JOIN status ON reports.casestat = status.id";
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
switch($row['casestat']){
case 0: $rwcol="#ff3c3c"; break;
case 1: $rwcol="#ffb93c"; break;
case 2:$rwcol="#ffff3c"; break;
case 3: $rwcol="#00bc00"; break;
case 4: $rwcol="#5a5aff"; break;
}
echo "<tr bgcolor=$rwcol>";
echo "<td id='code'>" . $row['id'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['class'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "<td>" . $row['created_at'] . "</td>";
echo "<td>" . $row['committed_at'] . "</td>";
echo "<td>" . $row['sender'] . "</td>";
echo "<td>" . $row['status'] . "</td>";
echo "<td><a onclick='updateStat(this.id)' id='".$row['id']."' href='#' ><abbr title='Edit'><i class='fa fa-edit'></i></abbr>Update Status</a> </tr>";}
?>
</tbody>
下面是它的样子:
也许bgcolor属性是由指定的。表条纹类覆盖您的标签。
+0
谢谢@wonyeouuu我的坏,我忘了它。 – JasonT
我认为故障在该行中:回声 “
是@GovindSamrow,引号是它的一部分。谢谢。 – JasonT
回答
也许bgcolor属性是由指定的。表条纹类覆盖您的标签。
.table-striped
谢谢@wonyeouuu我的坏,我忘了它。 – JasonT
相关问题