Posted by Bob Bedford on 12/15/05 12:01
"Ian B" <ianbambury@gmail.com> a écrit dans le message de news:
1134594287.504278.214300@g49g2000cwa.googlegroups.com...
> What happened there?
> Should have read:
>
>
> ZeldorBlat wrote:
>> Try an HTML or CSS newsgroup.
>
> Why? It's a programming problem.
>
> Try this:
>
>
> <html>
> <head>
> <title></title>
> <style>
>
> td
> {
> border : solid 1px blue;
> }
> .oddrow
> {
> background-color : #FFFFFF;
> }
> .evenrow
> {
> background-color : #CCCCCC;
> }
> #table1
> {
> border : solid 1px black;
> }
> </style>
> </head>
> <body>
> <?php
>
> $data = "Example of how to colour alternate lines";
> $data .= "<table id='table1'>";
> $colour = 0;
>
> for($i=1;$i<26;$i++)
> {
> $colour = -$colour - 1;
> $data .= ($colour)?'<tr class="oddrow">':'<tr class="evenrow">';
> $data .= "<td> Line $i </td>";
> $data .= "<td> Colour $colour </td>";
> $data .= '</tr>';
> }
> $data .= "</table>";
>
> echo $data;
> ?>
> </body>
> </html>
In fact even you example doesn't print grey lines. Try to make a preview and
look what I mean.
> for($i=1;$i<26;$i++)
> {
> $colour = -$colour - 1;
> $data .= ($colour)?'<tr class="oddrow">':'<tr class="evenrow">';
I've an other function, probably quicker ? (I hope)
for($line=1;$line<26;$line++)
echo '<td valign="top" nowrap class="'.((($line%2) ==
0)?"oddrow":"evenrow").'">'
And yes, it's probably more a question for CSS or HTML group than PHP.
Thanks for your tip.
Bob
Navigation:
[Reply to this message]
|