Kleuren bij tabellen
Mijn vraag is hoe ik mijn tabellen steeds een andere achtergrond kleur kan geven. Dus om de beurt de kleuren #B1ED2F en #A3D439. Het is dus de bedoeling dat mijn eerste tabel(bericht) de kleur #A3D439 krijgt en mijn tweede tabel(bericht) de andere kleur.
Weet iemand hoe ik dit kan doen?
Hieronder volgt mijn code.
Met vriendelijke groet,
Matthijs
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
include "config.php";
// Now select all (*) the fields from the table 'shoutbox'.
$queryResult = mysql_query("SELECT * FROM nieuws ORDER BY datum ASC", $dbLink);
// Start table
echo "<table width=\"240\" class=\"ktekst\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
// Print the contents of the table 'shoutbox'. The while loop will break
// there are no more rows. The rowData is an array with int as key.
while ($rowData = mysql_fetch_row($queryResult)) {
// Start row
echo "<tr>";
echo "<td width=\"15\"><img src=\"../images/nieuws_slices_17.gif\" width=\"15\" height=\"15\"></td>";
echo "<td width=\"240\" background=\"../images/nieuws_slices_19.gif\" height=\"15\" class=\"dik\">" . $rowData[1] . "</td>";
echo "<td width=\"240\" background=\"../images/nieuws_slices_19.gif\" height=\"15\"><div align=\"right\">::</div></td>";
echo "<td width=\"15\"><img src=\"../images/nieuws_slices_21.gif\" width=\"15\" height=\"15\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td height=\"24\" background=\"../images/nieuws_slices_28.gif\" height=\"18\"> </td>";
echo "<td colspan=\"2\" bgcolor=\"#D3FE59\" class=\"ktekst\">" . $rowData[2] . "</td>";
echo "<td background=\"../images/nieuws_slices_29.gif\" height=\"18\"> </td>";
echo "</tr>";
echo "<tr>";
echo "<td><img src=\"../images/nieuws_slices_35.gif\" width=\"15\" height=\"15\" height=\"15\"></td>";
echo "<td colspan=\"2\" class=\"ktekst\" background=\"../images/nieuws_slices_37.gif\" height=\"15\"></td>";
echo "<td><img src=\"../images/nieuws_slices_40.gif\" width=\"15\" height=\"15\" height=\"15\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td> </td>";
echo "</tr>";
}
// End table
echo "</table>";
?>
include "config.php";
// Now select all (*) the fields from the table 'shoutbox'.
$queryResult = mysql_query("SELECT * FROM nieuws ORDER BY datum ASC", $dbLink);
// Start table
echo "<table width=\"240\" class=\"ktekst\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
// Print the contents of the table 'shoutbox'. The while loop will break
// there are no more rows. The rowData is an array with int as key.
while ($rowData = mysql_fetch_row($queryResult)) {
// Start row
echo "<tr>";
echo "<td width=\"15\"><img src=\"../images/nieuws_slices_17.gif\" width=\"15\" height=\"15\"></td>";
echo "<td width=\"240\" background=\"../images/nieuws_slices_19.gif\" height=\"15\" class=\"dik\">" . $rowData[1] . "</td>";
echo "<td width=\"240\" background=\"../images/nieuws_slices_19.gif\" height=\"15\"><div align=\"right\">::</div></td>";
echo "<td width=\"15\"><img src=\"../images/nieuws_slices_21.gif\" width=\"15\" height=\"15\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td height=\"24\" background=\"../images/nieuws_slices_28.gif\" height=\"18\"> </td>";
echo "<td colspan=\"2\" bgcolor=\"#D3FE59\" class=\"ktekst\">" . $rowData[2] . "</td>";
echo "<td background=\"../images/nieuws_slices_29.gif\" height=\"18\"> </td>";
echo "</tr>";
echo "<tr>";
echo "<td><img src=\"../images/nieuws_slices_35.gif\" width=\"15\" height=\"15\" height=\"15\"></td>";
echo "<td colspan=\"2\" class=\"ktekst\" background=\"../images/nieuws_slices_37.gif\" height=\"15\"></td>";
echo "<td><img src=\"../images/nieuws_slices_40.gif\" width=\"15\" height=\"15\" height=\"15\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td> </td>";
echo "</tr>";
}
// End table
echo "</table>";
?>
Dus ik moet 2x de tabel maken alleen 1x in de if statement en 1x in de else? :)
Maar Jan heeft een hele korte methode bedacht:
Code (php)
Het lijkt me eigenlijk wel duidelijk waar alles moet.
Hoe kan ik dat regelen?
Dan kan je nog bij de css toevoegen:
tr.bg0 {
background: #A3D439 url(background.jpg) no-repeat fixed;
}
Ja , het was al gelukt! Hartelijk dank hiervoor!!