Reputation: 444
I want to make a table more readable by alternating row colours. I've been through the other answers but can't see how to apply them to my code. I tried various toggle methods in the last bit of the code but just broke everything.
I can't use jquery or CSS because I can only access this part of the code.
I want to toglle to 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>
Upvotes: 0
Views: 36
Reputation: 2002
I can't use jquery or CSS because I can only access this part of the code.
It's unclear as to which part of code you're referring. Assuming you can access all the code showed, you can place the <style>
tag before or after the <table>
.
It's as simple as defining n-th CSS like
<style>
/* tr:nth-child(odd) {background-color: #0000cc} */
tr:nth-child(even) {background-color: #D4E9FC}
</style>
Upvotes: 2