【发布时间】:2019-03-28 06:59:39
【问题描述】:
我想通过交替行颜色使表格更具可读性。我已经完成了其他答案,但看不到如何将它们应用到我的代码中。我在代码的最后一点尝试了各种切换方法,但只是破坏了一切。
我不能使用 jquery 或 CSS,因为我只能访问这部分代码。
我想切换到 bgcolor="#8BC6FD"
<table cellspacing=0 cellpadding=2 border="thin">
<col width=150>
<col width=100>
<tr bgcolor="#D4E9FC" style="outline: thin solid">
<td class="viewN"><b>TYPE:- </b></td>
<td class="viewN"><b>PACKING:- </b></td>
</tr>
<?php
$dbconn = pg_connect("host=127.0.0.1 XXXX password=YYYY)") or die('Could not connect: ' . pg_last_error());
$query = "SELECT * FROM stock
ORDER BY name" ;
$result = pg_query($query);
if (!$result) {
echo "Problem with query " . $query . "<br/>";
echo pg_last_error();
exit();
}
while($myrow = pg_fetch_assoc($result)) {
printf ("<tr><td>%s</td><td>%s</td></tr>", htmlspecialchars($myrow['type']),htmlspecialchars($myrow['packing']));
}
?>
</table>
【问题讨论】:
标签: php html-table