From: Ashley Sheridan on
On Wed, 2010-04-28 at 16:16 +0430, Ali Asghar Toraby Parizy wrote:

> It isn't good idea to use php to visualize your table. You can fetch
> you data by php and style them by java script.
>
> On Wed, Apr 28, 2010 at 3:59 PM, Juan Rodriguez Monti
> <juan(a)rodriguezmonti.com.ar> wrote:
> > Hello Guys,
> > I would like to implement a two color row table for some queries that I'm doing.
> >
> > I use PHP to query a DB, then I use while to print all its results. I
> > have a code pretty similar to this one :
> >
> > $results = Here the QUERY;
> > echo "<html>";
> > echo "<head>";
> > echo '<link rel="stylesheet" type="text/css" href="style.css" />';
> > echo "</head>";
> > echo "<body>";
> > echo '<div id="container">';
> >
> > echo "<center><h2>Results</h2></center><br />";
> > echo ("<table border='1'>");
> > echo "<td><strong>At1</strong></td>
> > <td><strong>At2</strong></td> <td><strong>At3</strong></td> $
> >
> > while ($row = while condition )) {
> > echo ("<tr>");
> > echo "<td>$row[0]</td><td>$row[1]</td> <td>$row[2]</td>
> > <td>$row[3]</td><td>$row[4]</td> ";
> > echo "</div>";
> > echo "</body>";
> > echo "</html>";
> >
> > I just want to show you how I write the table. What I would like to
> > know is what do you suggest to do a two color row format.
> >
> > Thanks!,
> > Juan
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>


Javascript is even less of a good idea, as it can be turned off and
isn't available on all browsers. PHP doesn't rely on the clients
browser, so is a safer bet.

Thanks,
Ash
http://www.ashleysheridan.co.uk


From: Juan Rodriguez Monti on
2010/4/28 Jay Blanchard <jblanchard(a)pocket.com>:
> [snip]
> I just want to show you how I write the table. What I would like to
> know is what do you suggest to do a two color row format.
> [/snip]
>
> Before your table;
>
> $trColor = 0;
>
> Then during the loop;
>
> while(foo){
> $tr = (0 == $trColor % 2)? "#E8E8E8" : "#FFFFFF";
> echo "<tr style=\"background-color:".$tr."\">";
> ...
>
> Replace the hex values with the colors you desire.

Thank you all for the replies!, I wanted something like this. It was
very useful.

I agree that JS might be turned off , and isn't in all browsers.

Best,
Juan
From: "Jay Blanchard" on
[snip]
> Before your table;
>
> $trColor = 0;
>
> Then during the loop;
>
> while(foo){
> $tr = (0 == $trColor % 2)? "#E8E8E8" : "#FFFFFF";
> echo "<tr style=\"background-color:".$tr."\">";
> ...
>
> Replace the hex values with the colors you desire.

Just one more question about this.

I'm getting something like this[0], and I would like to get something
like this[1] using something similar to Jay's suggestion.
[/snip]

My suggestion should produce the results you desire. Can you post your
current code?
From: Jochen Schultz on
Like this?

$color[0] = 'red';
$color[1] = 'blue';

for ($i=0;foo;$i++) {
echo '<tr style:background-color:'.$color[$i%2]...

regards
Jochen


Jay Blanchard schrieb:
> [snip]
>> Before your table;
>>
>> $trColor = 0;
>>
>> Then during the loop;
>>
>> while(foo){
>> $tr = (0 == $trColor % 2)? "#E8E8E8" : "#FFFFFF";
>> echo "<tr style=\"background-color:".$tr."\">";
>> ...
>>
>> Replace the hex values with the colors you desire.
>
> Just one more question about this.
>
> I'm getting something like this[0], and I would like to get something
> like this[1] using something similar to Jay's suggestion.
> [/snip]
>
> My suggestion should produce the results you desire. Can you post your
> current code?
>

--
Sport Import GmbH - Amtsgericht Oldenburg - Tel: +49-4405-9280-63
Industriestrasse 39 - HRB 1202900 -
26188 Edewecht - GF: Michael M�llmann
From: Juan Rodriguez Monti on
2010/4/28 Jay Blanchard <jblanchard(a)pocket.com>:
> [snip]
>> Before your table;
>>
>> $trColor = 0;
>>
>> Then during the loop;
>>
>> while(foo){
>> $tr = (0 == $trColor % 2)? "#E8E8E8" : "#FFFFFF";
>> echo "<tr style=\"background-color:".$tr."\">";
>> ...
>>
>> Replace the hex values with the colors you desire.
>
> Just one more question about this.
>
> I'm getting something like this[0], and I would like to get something
> like this[1] using something similar to Jay's suggestion.
> [/snip]
>
> My suggestion should produce the results you desire. Can you post your
> current code?

Yes!. Here is: http://pastebin.com/3vPfvssX

Juan.