Re: [PHP] Two color rows in table inside while iteration [X-PHP]

2010-05-06 Thread tedd

At 12:07 AM +0200 5/6/10, Michiel Sikma wrote:
On 2 May 2010 19:11, tedd 
mailto:tedd.sperl...@gmail.comtedd.sperl...@gmail.com wrote:



government rant

-snip-
Yes, it would be nice if the people who work for the government also 
had to live under the same rules as the rest of us. As it is, they 
live in a state of privilege enjoying salaries that are typically 
175 percent above that of the private sector with benefits to match. 
They do this without advancing the quality of life for anyone -- 
they have no purpose other than to push papers, collect *their* 
wages, enjoy *their* health insurance, and wait for *their* lavish 
retirement. Of course, they claim they have purpose, but most of us 
know better. The sooner we reduce the size and importance of 
government, the better off we all will be.


/government rant

Cheers,

tedd


Hello,

I'm not a moderator of this list, but I would like to ask you to 
please not use the PHP list for such confronting political 
diatribes. This is a very well known talking point that can easily 
elicit a lengthy off-topic discussion, and I don't think anybody is 
really interested in that.
Again, this is just my opinion, but while it's okay to talk about 
things other than PHP on occasion, I don't really see what use this 
has other than provoking a response from someone.


Please be considerate is all I'm asking.

Michiel


Michiel:

Considerate? Being Inconsiderate is what the government does for a living.

Additionally, what you said above is *your* opinion -- as *you* 
presented in a public forum. Who's opinion is more appropriate for 
this list is subject to debate.


As for me, I'll say whatever I want as the topic permits. If you will 
review this thread you will see that I was offering my code free to 
everyone except government. That's not an opinion but rather a 
statement of requirement for the code I'm providing. My second post 
to this thread contained the reason WHY the requirement.


If you don't like my requirements, and reasons for them, then please 
forward my postings to the trash and don't use my code.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration [X-PHP]

2010-05-06 Thread Michiel Sikma
On 6 May 2010 17:47, tedd tedd.sperl...@gmail.com wrote:


 Michiel:

 Considerate? Being Inconsiderate is what the government does for a living.

 Additionally, what you said above is *your* opinion -- as *you* presented
 in a public forum. Who's opinion is more appropriate for this list is
 subject to debate.

 As for me, I'll say whatever I want as the topic permits. If you will
 review this thread you will see that I was offering my code free to everyone
 except government. That's not an opinion but rather a statement of
 requirement for the code I'm providing. My second post to this thread
 contained the reason WHY the requirement.

 If you don't like my requirements, and reasons for them, then please
 forward my postings to the trash and don't use my code.


 Cheers,

 tedd


It appears as though I struck a wrong chord. I honestly did not mean to
upset you. :) My point was that we should not be overtly confrontational
towards one another, but it seems that only exacerbated the situation. My
sincerest apologies.

Regards,
Michiel


Re: [PHP] Two color rows in table inside while iteration -- just say no to mod

2010-05-05 Thread Michiel Sikma
On 3 May 2010 08:25, Jochen Schultz jschu...@sportimport.de wrote:

  [snip]

  And unless we are adding a multiple seconds to the load time is anyone
 going to notice a difference of 1 second?


 yes



It's really not that big a deal.
http://pastie.org/947121

Personally, I think using modulus is as nice a solution as flipping a bit.
Maybe more elegant since it's extendable to more than 2 states if required.

Michiel


Re: [PHP] Two color rows in table inside while iteration [X-PHP]

2010-05-05 Thread Michiel Sikma
On 2 May 2010 19:11, tedd tedd.sperl...@gmail.com wrote:


 government rant

 -snip-
 Yes, it would be nice if the people who work for the government also had to
 live under the same rules as the rest of us. As it is, they live in a state
 of privilege enjoying salaries that are typically 175 percent above that of
 the private sector with benefits to match. They do this without advancing
 the quality of life for anyone -- they have no purpose other than to push
 papers, collect *their* wages, enjoy *their* health insurance, and wait for
 *their* lavish retirement. Of course, they claim they have purpose, but most
 of us know better. The sooner we reduce the size and importance of
 government, the better off we all will be.

 /government rant

 Cheers,

 tedd


Hello,

I'm not a moderator of this list, but I would like to ask you to please not
use the PHP list for such confronting political diatribes. This is a very
well known talking point that can easily elicit a lengthy off-topic
discussion, and I don't think anybody is really interested in that.
Again, this is just my opinion, but while it's okay to talk about things
other than PHP on occasion, I don't really see what use this has other than
provoking a response from someone.

Please be considerate is all I'm asking.

Michiel


Re: [PHP] Two color rows in table inside while iteration -- just say no to mod

2010-05-03 Thread Jochen Schultz

 [snip]
And unless we are adding a multiple seconds to the load time is anyone 
going to notice a difference of 1 second? 


yes


regards
Jochen

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration [X-PHP]

2010-05-02 Thread tedd

At 11:53 PM -0400 5/1/10, Paul M Foster wrote:

On Fri, Apr 30, 2010 at 01:52:25PM -0400, tedd wrote:

  All the code I provide on this list and on my various web sites is

 for free for anyone, except for governments (i.e., local, state,
 federal, other), to use, review, and/or comment as they wish without
 any obligation to me. Oh, as for governments if you want a copy of
 anything please contact me directly, I have a few forms for you to
 fill out.


If you think about it, that's pretty hilarious. Normally, doing anything
with the government requires *you* to fill out a few forms. Making
*them* do it to use your stuff is humorously appropriate.

Paul



Paul:

government rant

That wasn't an original idea of mine, but something I experienced in 
my last life when I was employed in petroleum exploration industry 
(see http://geophysics.com). That was before the US Government 
declared OIL a four letter word.


At that time there was an Oil Company who was a client of mine and 
they owned a parking structure in Dallas. The Federal government 
asked for a suit of parking spaces from them to lease. The company 
relied with a list of required documents for the Feds to fill-out 
which included proof as to the Feds complying with OSHA, EPA, IRS, 
ADA, and so on. It made the local papers.


Yes, it would be nice if the people who work for the government also 
had to live under the same rules as the rest of us. As it is, they 
live in a state of privilege enjoying salaries that are typically 175 
percent above that of the private sector with benefits to match. They 
do this without advancing the quality of life for anyone -- they have 
no purpose other than to push papers, collect *their* wages, enjoy 
*their* health insurance, and wait for *their* lavish retirement. Of 
course, they claim they have purpose, but most of us know better. The 
sooner we reduce the size and importance of government, the better 
off we all will be.


/government rant

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration

2010-05-02 Thread Nathan Rixham
Paul M Foster wrote:
 On Fri, Apr 30, 2010 at 01:52:25PM -0400, tedd wrote:
 
 At 10:34 AM -0400 4/30/10, Paul M Foster wrote:
 On Thu, Apr 29, 2010 at 05:34:38PM -0400, tedd wrote:

   Please critically review my example.

 +1

 This thread came up before, and tedd's solution was the least complex,
 as far as I could tell. I shamelessly stole his code and regularly use
 it in my own projects. ;-}

 Paul
 Paul:

 Thanks for the plug.

 All the code I provide on this list and on my various web sites is
 for free for anyone, except for governments (i.e., local, state,
 federal, other), to use, review, and/or comment as they wish without
 any obligation to me. Oh, as for governments if you want a copy of
 anything please contact me directly, I have a few forms for you to
 fill out.
 
 If you think about it, that's pretty hilarious. Normally, doing anything
 with the government requires *you* to fill out a few forms. Making
 *them* do it to use your stuff is humorously appropriate.

Tedd,

That's awesome.

Best,

Nathan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration -- just say no to mod

2010-05-01 Thread Richard Quadling
On 30 April 2010 21:20, Daevid Vincent dae...@daevid.com wrote:
 -Original Message-
 From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk]

 Modulus is the most elegant solution I reckon. Imagine if you only
 needed to highlight every 3rd row, or 4th? Easy to change the modulus
 for it, not so easy to re-work a binary switch.

 -Original Message-
 From: Richard Quadling [mailto:rquadl...@googlemail.com]

 The modulus is a good option when there are more than 2 states.

 Say a 5 row fade ...

 $a=0;
 while ($row=mysql_fetch_...){
 echo tr class=??\alternate-row-.(1 + (++$a%5)).\...
 }

 giving alternate-row-1, alternate-row-2, alternate-row-3,
 alternate-row-4 and alternate-row-5

 Okay, how many tables do you EVER see with more than TWO colors? Come on
 now.

 Show me some URL's to REAL sites (not some contrived examples) that use
 multiple row colors or fades in a rotating fashion. Not talking about a
 highlight roll-over, nor am I talking about highlighting rows of certain
 criteria in different colors, as both of those are not the problem for this
 solution. I'm talking about a straight up table that cycles each row more
 than 2 colors.

 99% of your tables are 2 colors, and flipping a bit (i.e. Boolean) is WAY
 faster to compute than modulus and also easier to understand.

 http://www.youtube.com/watch?v=pXhKzY0BKwY  ;-) (I say that out of love!)

 d


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



Ha. OK, I actually do use a bit toggle for assigning a CSS class to
the alternative rows. But I did once use % where the table represented
a top10 list.



-- 
-
Richard Quadling
Standing on the shoulders of some very clever giants!
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration

2010-05-01 Thread Paul M Foster
On Fri, Apr 30, 2010 at 01:52:25PM -0400, tedd wrote:

 At 10:34 AM -0400 4/30/10, Paul M Foster wrote:
 On Thu, Apr 29, 2010 at 05:34:38PM -0400, tedd wrote:

   Please critically review my example.

 +1

 This thread came up before, and tedd's solution was the least complex,
 as far as I could tell. I shamelessly stole his code and regularly use
 it in my own projects. ;-}

 Paul

 Paul:

 Thanks for the plug.

 All the code I provide on this list and on my various web sites is
 for free for anyone, except for governments (i.e., local, state,
 federal, other), to use, review, and/or comment as they wish without
 any obligation to me. Oh, as for governments if you want a copy of
 anything please contact me directly, I have a few forms for you to
 fill out.

If you think about it, that's pretty hilarious. Normally, doing anything
with the government requires *you* to fill out a few forms. Making
*them* do it to use your stuff is humorously appropriate.

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Two color rows in table inside while iteration

2010-04-30 Thread Daevid Vincent
 -Original Message-
 while(foo){
 $tr = (0 == $trColor % 2)? #E8E8E8 : #FF;
 echo tr style=\background-color:.$tr.\;
 ...

Don't do this modulus (%) math Just toggle a boolean!!

tr class=?= ($r = !$r) ? dataRow1 : dataRow2; ?


smime.p7s
Description: S/MIME cryptographic signature


RE: [PHP] Two color rows in table inside while iteration

2010-04-30 Thread Ashley Sheridan
On Fri, 2010-04-30 at 06:14 -0500, Jay Blanchard wrote:

 [snip]
 Don't do this modulus (%) math Just toggle a boolean!!
 
 tr class=?= ($r = !$r) ? dataRow1 : dataRow2; ?
 [/snip]
 
 What is wrong with modulus math
 


Modulus is the most elegant solution I reckon. Imagine if you only
needed to highlight every 3rd row, or 4th? Easy to change the modulus
for it, not so easy to re-work a binary switch. 

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




Re: [PHP] Two color rows in table inside while iteration

2010-04-30 Thread Jay Ess

Paul M Foster wrote:

+1

This thread came up before, and tedd's solution was the least complex,
as far as I could tell. I shamelessly stole his code and regularly use
it in my own projects. ;-}
  

Or if one choose to use Smarty template.
tr bgcolor={cycle values=#ee,#d0d0d0}

http://www.smarty.net/manual/en/language.function.cycle.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration

2010-04-30 Thread tedd

At 10:34 AM -0400 4/30/10, Paul M Foster wrote:

On Thu, Apr 29, 2010 at 05:34:38PM -0400, tedd wrote:

  Please critically review my example.

+1

This thread came up before, and tedd's solution was the least complex,
as far as I could tell. I shamelessly stole his code and regularly use
it in my own projects. ;-}

Paul


Paul:

Thanks for the plug.

All the code I provide on this list and on my various web sites is 
for free for anyone, except for governments (i.e., local, state, 
federal, other), to use, review, and/or comment as they wish without 
any obligation to me. Oh, as for governments if you want a copy of 
anything please contact me directly, I have a few forms for you to 
fill out.


The point of sharing is to improve product -- agile works.

My livelihood is not compromised because someone is using a small 
snip-it of mine. Hopefully my real code (the stuff I sell to clients) 
is more involved and has more value than that.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration

2010-04-30 Thread tedd

At 4:37 PM +0200 4/30/10, Jay Ess wrote:

Paul M Foster wrote:

+1

This thread came up before, and tedd's solution was the least complex,
as far as I could tell. I shamelessly stole his code and regularly use
it in my own projects. ;-}


Or if one choose to use Smarty template.
tr bgcolor={cycle values=#ee,#d0d0d0}

http://www.smarty.net/manual/en/language.function.cycle.php


Yeah, like that keeps presentation separate from data while making 
things simpler, right? I don't think so.


Embedding styling attributes in html is simply not following best practices.

For example, if you have 100 pages of the above embedded code and the 
client says Hey, let's change the color of that table -- then you 
are going to have to change 100 pages of code whereas if you followed 
best practices then you would change only one rule in css.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration

2010-04-30 Thread Ashley Sheridan
On Fri, 2010-04-30 at 13:59 -0400, tedd wrote:

 At 4:37 PM +0200 4/30/10, Jay Ess wrote:
 Paul M Foster wrote:
 +1
 
 This thread came up before, and tedd's solution was the least complex,
 as far as I could tell. I shamelessly stole his code and regularly use
 it in my own projects. ;-}
 
 Or if one choose to use Smarty template.
 tr bgcolor={cycle values=#ee,#d0d0d0}
 
 http://www.smarty.net/manual/en/language.function.cycle.php
 
 Yeah, like that keeps presentation separate from data while making 
 things simpler, right? I don't think so.
 
 Embedding styling attributes in html is simply not following best practices.
 
 For example, if you have 100 pages of the above embedded code and the 
 client says Hey, let's change the color of that table -- then you 
 are going to have to change 100 pages of code whereas if you followed 
 best practices then you would change only one rule in css.
 
 Cheers,
 
 tedd
 
 -- 
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com
 


I agree. Inline styles are useful in a few fringe cases, but if you can
avoid them then it's best practice to do so.

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




Re: [PHP] Two color rows in table inside while iteration

2010-04-30 Thread tedd

At 7:26 PM +0100 4/30/10, Ashley Sheridan wrote:

On Fri, 2010-04-30 at 13:59 -0400, tedd wrote:
At 4:37 PM +0200 4/30/10, Jay Ess wrote:

Paul M Foster wrote:

+1

This thread came up before, and tedd's solution was the least complex,
as far as I could tell. I shamelessly stole his code and regularly use
it in my own projects. ;-}


Or if one choose to use Smarty template.
tr bgcolor={cycle values=#ee,#d0d0d0}

http://www.smarty.net/manual/en/language.function.cycle.phphttp://www.smarty.net/manual/en/language.function.cycle.php


Yeah, like that keeps presentation separate from data while making
things simpler, right? I don't think so.

Embedding styling attributes in html is simply not following best 
practices.


For example, if you have 100 pages of the above embedded code and the
client says Hey, let's change the color of that table -- then you
are going to have to change 100 pages of code whereas if you followed
best practices then you would change only one rule in css.

Cheers,

tedd


I agree. Inline styles are useful in a few fringe cases, but if you 
can avoid them then it's best practice to do so.


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


Ash:

The only fringe cases I can think of are those that could be solved 
by using a span tag.


Do you have any examples otherwise?

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Two color rows in table inside while iteration -- just say no to mod

2010-04-30 Thread Daevid Vincent
 -Original Message-
 From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
 
 Modulus is the most elegant solution I reckon. Imagine if you only
 needed to highlight every 3rd row, or 4th? Easy to change the modulus
 for it, not so easy to re-work a binary switch. 

 -Original Message-
 From: Richard Quadling [mailto:rquadl...@googlemail.com] 
 
 The modulus is a good option when there are more than 2 states.
 
 Say a 5 row fade ...
 
 $a=0;
 while ($row=mysql_fetch_...){
 echo tr class=??\alternate-row-.(1 + (++$a%5)).\...
 }
 
 giving alternate-row-1, alternate-row-2, alternate-row-3,
 alternate-row-4 and alternate-row-5

Okay, how many tables do you EVER see with more than TWO colors? Come on
now.

Show me some URL's to REAL sites (not some contrived examples) that use
multiple row colors or fades in a rotating fashion. Not talking about a
highlight roll-over, nor am I talking about highlighting rows of certain
criteria in different colors, as both of those are not the problem for this
solution. I'm talking about a straight up table that cycles each row more
than 2 colors.

99% of your tables are 2 colors, and flipping a bit (i.e. Boolean) is WAY
faster to compute than modulus and also easier to understand.

http://www.youtube.com/watch?v=pXhKzY0BKwY  ;-) (I say that out of love!)

d


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration

2010-04-30 Thread Ashley Sheridan
On Fri, 2010-04-30 at 15:59 -0400, tedd wrote:

 At 7:26 PM +0100 4/30/10, Ashley Sheridan wrote:
 On Fri, 2010-04-30 at 13:59 -0400, tedd wrote:
 At 4:37 PM +0200 4/30/10, Jay Ess wrote:
 Paul M Foster wrote:
 +1
 
 This thread came up before, and tedd's solution was the least complex,
 as far as I could tell. I shamelessly stole his code and regularly use
 it in my own projects. ;-}
 
 Or if one choose to use Smarty template.
 tr bgcolor={cycle values=#ee,#d0d0d0}
 
 http://www.smarty.net/manual/en/language.function.cycle.phphttp://www.smarty.net/manual/en/language.function.cycle.php
 
 Yeah, like that keeps presentation separate from data while making
 things simpler, right? I don't think so.
 
 Embedding styling attributes in html is simply not following best 
 practices.
 
 For example, if you have 100 pages of the above embedded code and the
 client says Hey, let's change the color of that table -- then you
 are going to have to change 100 pages of code whereas if you followed
 best practices then you would change only one rule in css.
 
 Cheers,
 
 tedd
 
 I agree. Inline styles are useful in a few fringe cases, but if you 
 can avoid them then it's best practice to do so.
 
 Thanks,
 Ash
 http://www.ashleysheridan.co.ukhttp://www.ashleysheridan.co.uk
 
 Ash:
 
 The only fringe cases I can think of are those that could be solved 
 by using a span tag.
 
 Do you have any examples otherwise?
 
 Cheers,
 
 tedd


I can't think of any right now, but I know that on occassion I've used
inline styles where I know that the style will never be repeated and was
a one-off style to just perform a quick fix. I know it's a messy thing
to do, but I'm sure there must be a good reason for them somewhere!

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




Re: [PHP] Two color rows in table inside while iteration -- just say no to mod

2010-04-30 Thread Jason Pruim


On Apr 30, 2010, at 4:20 PM, Daevid Vincent wrote:


-Original Message-
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk]

Modulus is the most elegant solution I reckon. Imagine if you only
needed to highlight every 3rd row, or 4th? Easy to change the modulus
for it, not so easy to re-work a binary switch.

-Original Message-
From: Richard Quadling [mailto:rquadl...@googlemail.com]

The modulus is a good option when there are more than 2 states.

Say a 5 row fade ...

$a=0;
while ($row=mysql_fetch_...){
echo tr class=??\alternate-row-.(1 + (++$a%5)).\...
}

giving alternate-row-1, alternate-row-2, alternate-row-3,
alternate-row-4 and alternate-row-5


Okay, how many tables do you EVER see with more than TWO colors?  
Come on

now.

Show me some URL's to REAL sites (not some contrived examples) that  
use
multiple row colors or fades in a rotating fashion. Not talking  
about a
highlight roll-over, nor am I talking about highlighting rows of  
certain
criteria in different colors, as both of those are not the problem  
for this
solution. I'm talking about a straight up table that cycles each row  
more

than 2 colors.

99% of your tables are 2 colors, and flipping a bit (i.e. Boolean)  
is WAY

faster to compute than modulus and also easier to understand.

http://www.youtube.com/watch?v=pXhKzY0BKwY  ;-) (I say that out of  
love!)



A bit of a contrived example... BUT... I could envision having  
multiple (more then 2) colors on a blog with comments...


Maybe it's a patriotic blog and they want the comments to cycle  
between red, white  blue... (Or your countries colors) And yes I know  
that you could assume white is a default... But I know some people who  
have the default color of their web browser set to bright pink to  
point out where rules aren't specifically assigned :)


And unless we are adding a multiple seconds to the load time is anyone  
going to notice a difference of 1 second? Or am I wrong?


Also... I'm not trying to start a fight... Just trying to understand  
the different possibilities and the impact :) Hoping to write the next  
facebook eventually But aren't we all? ;)




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration

2010-04-29 Thread tedd

At 8:29 AM -0300 4/28/10, Juan Rodriguez Monti 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 centerh2Results/h2/centerbr /;
echo (table border='1');
echo tdstrongAt1/strong/td
tdstrongAt2/strong/td tdstrongAt3/strong/td  $

  while ($row = while condition )) {
echo (tr);
echo td$row[0]/tdtd$row[1]/td td$row[2]/td
td$row[3]/tdtd$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



Juan:

Everyone has done this at one time or another -- this is my solution.

http://webbytedd.com/b/color-rows/

Plus, it validates and keeps things simple.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration

2010-04-29 Thread Juan Rodriguez Monti
2010/4/29 tedd tedd.sperl...@gmail.com:
 At 8:29 AM -0300 4/28/10, Juan Rodriguez Monti 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 centerh2Results/h2/centerbr /;
        echo (table border='1');
        echo tdstrongAt1/strong/td
 tdstrongAt2/strong/td tdstrongAt3/strong/td      $

  while ($row = while condition )) {
        echo (tr);
        echo td$row[0]/tdtd$row[1]/td td$row[2]/td
 td$row[3]/tdtd$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


 Juan:

 Everyone has done this at one time or another -- this is my solution.

 http://webbytedd.com/b/color-rows/

 Plus, it validates and keeps things simple.

 Cheers,

 tedd

Tedd,
Thanks. I'm gonna check it. I finally solved it using:

if ( CONDITIONS )) {

  $results = query( QUERY );
 $colors = array('#97b7cd','#96bf8c');
 $index= 0; 
echo html;
echo head;
echo 'link rel=stylesheet type=text/css href=is.css /';
echo /head;
echo body;
echo 'div id=container';

echo table border='1';
echo tdstronga1/strong/td tdstronga2/strong/td
tdstronga3/strong/td tdstronga4/strong/td
tdstronga5/strong/td ;

  while ($row = CONDITIONS )) {
echo 'tr style=background-color: ' .  $colors[$index ++ %  2] .  
';';   
echo td$row[0]/tdtd$row[1]/td td$row[2]/td
td$row[3]/tdtd$row[4]/td ;
  }
echo /tr;
echo /table;
echo /div;
echo 'pa href=back.htmlback/a/p';
echo /body;
echo /html;

This solution was the best for me. It's solved with your help.

Thanks a lot!.

Juan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration

2010-04-29 Thread tedd

At 11:01 AM -0300 4/29/10, Juan Rodriguez Monti wrote:

2010/4/29 tedd tedd.sperl...@gmail.com:

 At 8:29 AM -0300 4/28/10, Juan Rodriguez Monti 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 centerh2Results/h2/centerbr /;
echo (table border='1');
echo tdstrongAt1/strong/td
 tdstrongAt2/strong/td tdstrongAt3/strong/td  $

  while ($row = while condition )) {
echo (tr);
echo td$row[0]/tdtd$row[1]/td td$row[2]/td
 td$row[3]/tdtd$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



 Juan:

 Everyone has done this at one time or another -- this is my solution.

 http://webbytedd.com/b/color-rows/

 Plus, it validates and keeps things simple.

 Cheers,

 tedd


Tedd,
Thanks. I'm gonna check it. I finally solved it using:

if ( CONDITIONS )) {

  $results = query( QUERY );
 $colors = array('#97b7cd','#96bf8c');
 $index= 0;
echo html;
echo head;
echo 'link rel=stylesheet type=text/css href=is.css /';
echo /head;
echo body;
echo 'div id=container';

echo table border='1';
echo tdstronga1/strong/td tdstronga2/strong/td
tdstronga3/strong/td tdstronga4/strong/td
tdstronga5/strong/td ;

  while ($row = CONDITIONS )) {
	echo 'tr style=background-color: ' .  $colors[$index ++ % 
2] .  ';';  
	echo td$row[0]/tdtd$row[1]/td td$row[2]/td

td$row[3]/tdtd$row[4]/td ;
  }
echo /tr;
echo /table;
echo /div;
echo 'pa href=back.htmlback/a/p';
echo /body;
echo /html;

This solution was the best for me. It's solved with your help.

Thanks a lot!.

Juan


The above is far more complicated than it has to be.

Please critically review my example.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration

2010-04-29 Thread shiplu
$a=0;
while (++$a, $row=mysql_fetch_...){
echo tr class=‌‌\alternate-row-.($a%2).\...
}


Shiplu Mokaddim
My talks, http://talk.cmyweb.net
Follow me, http://twitter.com/shiplu
SUST Programmers, http://groups.google.com/group/p2psust
Innovation distinguishes bet ... ... (ask Steve Jobs the rest)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Ashley Sheridan
On Wed, 2010-04-28 at 08:29 -0300, Juan Rodriguez Monti 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 centerh2Results/h2/centerbr /;
 echo (table border='1');
 echo tdstrongAt1/strong/td
 tdstrongAt2/strong/td tdstrongAt3/strong/td  $
 
   while ($row = while condition )) {
 echo (tr);
 echo td$row[0]/tdtd$row[1]/td td$row[2]/td
 td$row[3]/tdtd$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
 


You look to be converting the database rows into table columns there, so
which do you want to style, the rows or the columns?

Basically, I'd do something like this that I wrote a while back:

http://www.ashleysheridan.co.uk/coding_php_alternate_rows.php

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




RE: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Jay Blanchard
[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 : #FF;
echo tr style=\background-color:.$tr.\;
...

Replace the hex values with the colors you desire.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Gary .
On 4/28/10, Juan Rodriguez Monti wrote:
 I would like to implement a two color row table for some queries that I'm
 doing.
...
 what do you suggest to do a two color row format.

Well, I wouldn't mix the presentation and querying of the db in one
place, but assuming that's just a simplified example... I'd just set
each tr style name to something relevant declared in your CSS.
Alternating rows getting style names like odd, and even, which are
declared in CSS to display in different colours, or whatever.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Ali Asghar Toraby Parizy
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
j...@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 centerh2Results/h2/centerbr /;
        echo (table border='1');
        echo tdstrongAt1/strong/td
 tdstrongAt2/strong/td tdstrongAt3/strong/td      $

  while ($row = while condition )) {
        echo (tr);
        echo td$row[0]/tdtd$row[1]/td td$row[2]/td
 td$row[3]/tdtd$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



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Ashley Sheridan
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
 j...@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 centerh2Results/h2/centerbr /;
 echo (table border='1');
 echo tdstrongAt1/strong/td
  tdstrongAt2/strong/td tdstrongAt3/strong/td  $
 
   while ($row = while condition )) {
 echo (tr);
 echo td$row[0]/tdtd$row[1]/td td$row[2]/td
  td$row[3]/tdtd$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




Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Juan Rodriguez Monti
2010/4/28 Jay Blanchard jblanch...@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 : #FF;
 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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Jay Blanchard
[snip]
 Before your table;

 $trColor = 0;

 Then during the loop;

 while(foo){
 $tr = (0 == $trColor % 2)? #E8E8E8 : #FF;
 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?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Jochen Schultz

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 : #FF;
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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Juan Rodriguez Monti
2010/4/28 Jay Blanchard jblanch...@pocket.com:
 [snip]
 Before your table;

 $trColor = 0;

 Then during the loop;

 while(foo){
 $tr = (0 == $trColor % 2)? #E8E8E8 : #FF;
 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.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Ali Asghar Toraby Parizy
I agree with you. in this simple example we can use php but we may need
table with extra functionality and only client side scripts are reasonable
and applicable. we can create multi color and clickable rows by php but
we'll have greater server load.
anyway that was only an propose;-)

On Wed, Apr 28, 2010 at 4:12 PM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:

  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
 j...@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 centerh2Results/h2/centerbr /;
 echo (table border='1');
 echo tdstrongAt1/strong/td
  tdstrongAt2/strong/td tdstrongAt3/strong/td  $
 
   while ($row = while condition )) {
 echo (tr);
 echo td$row[0]/tdtd$row[1]/td td$row[2]/td
  td$row[3]/tdtd$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





Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Fernando

What about this:

$color = even;
while ($row = while condition )) {
   $color = ($color == even) ? odd : even;
   echo (tr class=\$color\);
   echo td$row[0]/tdtd$row[1]/td  
td$row[2]/tdtd$row[3]/tdtd$row[4]/td  ;
   echo (/tr)
}

And have two classes in your style sheet that format each row differently.

Hope this helps.


On 28/04/2010 09:29, Ali Asghar Toraby Parizy wrote:

I agree with you. in this simple example we can use php but we may need
table with extra functionality and only client side scripts are reasonable
and applicable. we can create multi color and clickable rows by php but
we'll have greater server load.
anyway that was only an propose;-)

On Wed, Apr 28, 2010 at 4:12 PM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:

   

  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
j...@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 centerh2Results/h2/centerbr /;
echo (table border='1');
echo tdstrongAt1/strong/td
tdstrongAt2/strong/td  tdstrongAt3/strong/td   $

  while ($row = while condition )) {
echo (tr);
echo td$row[0]/tdtd$row[1]/td  td$row[2]/td
td$row[3]/tdtd$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



 
   


Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Ashley Sheridan
On Wed, 2010-04-28 at 17:59 +0430, Ali Asghar Toraby Parizy wrote:

 I agree with you. in this simple example we can use php but we may
 need table with extra functionality and only client side scripts are
 reasonable and applicable. we can create multi color and clickable
 rows by php but we'll have greater server load.
 anyway that was only an propose;-)
 
 
 On Wed, Apr 28, 2010 at 4:12 PM, Ashley Sheridan
 a...@ashleysheridan.co.uk wrote:
 
 
 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
  j...@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 centerh2Results/h2/centerbr /;
  echo (table border='1');
  echo tdstrongAt1/strong/td
   tdstrongAt2/strong/td tdstrongAt3/strong/td  $
  
while ($row = while condition )) {
  echo (tr);
  echo td$row[0]/tdtd$row[1]/td td$row[2]/td
   td$row[3]/tdtd$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
 
 
 
 
 


I just feel it's often a false economy. Relying too heavily on
Javascript for something that can be achieved with a little work on the
server is not good. I'm a big supporter of accessibility, and for me,
using Javascript to provide essential functionality is best avoided. I
agree that some things cannot be done (imagine if Google Docs tried not
using Javascript!) It's a topic that has come up now and again on the
list.

For the best results build the site so that all the raw functionality is
there, and then use Javascript after to enhance that. So you could
create a site that has all its contents output by PHP and navigates
using standard links, then have Javascript that re-writes the links to
make Ajax calls. Turn off Javascript and everything will still work, but
turn it on, and suddenly things work a bit better. No functionality is
lost, it's just been changed slightly.

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




Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Ashley Sheridan
On Wed, 2010-04-28 at 09:34 -0400, Fernando wrote:

 What about this:
 
 $color = even;
 while ($row = while condition )) {
 $color = ($color == even) ? odd : even;
 echo (tr class=\$color\);
 echo td$row[0]/tdtd$row[1]/td  
 td$row[2]/tdtd$row[3]/tdtd$row[4]/td  ;
 echo (/tr)
 }
 
 And have two classes in your style sheet that format each row differently.
 
 Hope this helps.
 
 
 On 28/04/2010 09:29, Ali Asghar Toraby Parizy wrote:
  I agree with you. in this simple example we can use php but we may need
  table with extra functionality and only client side scripts are reasonable
  and applicable. we can create multi color and clickable rows by php but
  we'll have greater server load.
  anyway that was only an propose;-)
 
  On Wed, Apr 28, 2010 at 4:12 PM, Ashley Sheridan
  a...@ashleysheridan.co.ukwrote:
 
 
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
  j...@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 centerh2Results/h2/centerbr /;
  echo (table border='1');
  echo tdstrongAt1/strong/td
  tdstrongAt2/strong/td  tdstrongAt3/strong/td   $
 
while ($row = while condition )) {
  echo (tr);
  echo td$row[0]/tdtd$row[1]/td  td$row[2]/td
  td$row[3]/tdtd$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
 
 
 
   
 


You really only need one alternate row class, as I showed in my earlier
example. All the rows are styled using the tables default CSS, and then
you just style the rows you want to change from that default. Here it is
again :p

http://www.ashleysheridan.co.uk/coding_php_alternate_rows.php

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




Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Fernando
But then you need to differentiate the table, otherwise all your tables 
will have the same row formating no?  This way you only apply the 
formating to those rows that need it.


Fernando.

On 28/04/2010 09:35, Ashley Sheridan wrote:

On Wed, 2010-04-28 at 09:34 -0400, Fernando wrote:

   

What about this:

$color = even;
while ($row = while condition )) {
 $color = ($color == even) ? odd : even;
 echo (tr class=\$color\);
 echo td$row[0]/tdtd$row[1]/td   
td$row[2]/tdtd$row[3]/tdtd$row[4]/td   ;
 echo (/tr)
}

And have two classes in your style sheet that format each row differently.

Hope this helps.


On 28/04/2010 09:29, Ali Asghar Toraby Parizy wrote:
 

I agree with you. in this simple example we can use php but we may need
table with extra functionality and only client side scripts are reasonable
and applicable. we can create multi color and clickable rows by php but
we'll have greater server load.
anyway that was only an propose;-)

On Wed, Apr 28, 2010 at 4:12 PM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:


   

   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
j...@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 centerh2Results/h2/centerbr /;
 echo (table border='1');
 echo tdstrongAt1/strong/td
tdstrongAt2/strong/td   tdstrongAt3/strong/td$

   while ($row = while condition )) {
 echo (tr);
 echo td$row[0]/tdtd$row[1]/td   td$row[2]/td
td$row[3]/tdtd$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




 


   


You really only need one alternate row class, as I showed in my earlier
example. All the rows are styled using the tables default CSS, and then
you just style the rows you want to change from that default. Here it is
again :p

http://www.ashleysheridan.co.uk/coding_php_alternate_rows.php

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



   


Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Ashley Sheridan
On Wed, 2010-04-28 at 09:46 -0400, Fernando wrote:

 But then you need to differentiate the table, otherwise all your tables 
 will have the same row formating no?  This way you only apply the 
 formating to those rows that need it.
 
 Fernando.
 
 On 28/04/2010 09:35, Ashley Sheridan wrote:
  On Wed, 2010-04-28 at 09:34 -0400, Fernando wrote:
 
 
  What about this:
 
  $color = even;
  while ($row = while condition )) {
   $color = ($color == even) ? odd : even;
   echo (tr class=\$color\);
   echo td$row[0]/tdtd$row[1]/td   
  td$row[2]/tdtd$row[3]/tdtd$row[4]/td   ;
   echo (/tr)
  }
 
  And have two classes in your style sheet that format each row differently.
 
  Hope this helps.
 
 
  On 28/04/2010 09:29, Ali Asghar Toraby Parizy wrote:
   
  I agree with you. in this simple example we can use php but we may need
  table with extra functionality and only client side scripts are reasonable
  and applicable. we can create multi color and clickable rows by php but
  we'll have greater server load.
  anyway that was only an propose;-)
 
  On Wed, Apr 28, 2010 at 4:12 PM, Ashley Sheridan
  a...@ashleysheridan.co.ukwrote:
 
 
 
 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
  j...@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 centerh2Results/h2/centerbr /;
   echo (table border='1');
   echo tdstrongAt1/strong/td
  tdstrongAt2/strong/td   tdstrongAt3/strong/td$
 
 while ($row = while condition )) {
   echo (tr);
   echo td$row[0]/tdtd$row[1]/td   td$row[2]/td
  td$row[3]/tdtd$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
 
 
 
 
   
 
 
 
  You really only need one alternate row class, as I showed in my earlier
  example. All the rows are styled using the tables default CSS, and then
  you just style the rows you want to change from that default. Here it is
  again :p
 
  http://www.ashleysheridan.co.uk/coding_php_alternate_rows.php
 
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 
 
 
 


Yes, but one would assume you'd be doing that anyway if you needed this
table to be displayed differently from all the others on your page?

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




Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Juan Rodriguez Monti
2010/4/28 Fernando ferna...@ggtours.ca:
 What about this:

 $color = even;
 while ($row = while condition )) {
       $color = ($color == even) ? odd : even;
       echo (tr class=\$color\);
       echo td$row[0]/tdtd$row[1]/td
  td$row[2]/tdtd$row[3]/tdtd$row[4]/td  ;
       echo (/tr)
 }

 And have two classes in your style sheet that format each row differently.

 Hope this helps.

Thanks to all guys!. Now it's working perfectly as I wanted.

Also was interesting to read the points you showed about JS and PHP.

Best,
Juan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Bob McConnell
From: Ashley Sheridan
 On Wed, 2010-04-28 at 09:46 -0400, Fernando wrote:
 
 But then you need to differentiate the table, otherwise all your
tables 
 will have the same row formating no?  This way you only apply the 
 formating to those rows that need it.
 
 Yes, but one would assume you'd be doing that anyway if you needed
this
 table to be displayed differently from all the others on your page?

The alternate colors should be in a CSS style linked to the TR tag. The
base table style is used for the odd rows, with the alternate colors for
the even rows. It's very easy to create multiple variations that way.

Javascript is definitely out. Only a fool or an imbecile intentionally
enables primary malware infection vectors like that. I believe Firefox
should install the NoScript add-on by default with maximum protection
enabled.

Bob McConnell

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Richard Quadling
On 28 April 2010 12:29, Juan Rodriguez Monti j...@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 centerh2Results/h2/centerbr /;
        echo (table border='1');
        echo tdstrongAt1/strong/td
 tdstrongAt2/strong/td tdstrongAt3/strong/td      $

  while ($row = while condition )) {
        echo (tr);
        echo td$row[0]/tdtd$row[1]/td td$row[2]/td
 td$row[3]/tdtd$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



As everyone and their dog has a way ...

My loop contains ...

$Odd = $Odd ? '' : ' class=odd';
$Rows .=  END_HTML_ROW
tr $Odd
th{$RemovalReason-UniqueID}/th
td{$RemovalReason-RemovalReason}/td
td{$RemovalReason-DateAdded}/td
td{$RemovalReason-DateRemoved}/td
/tr
END_HTML_ROW;

So, the table has a standard style and odd rows are tagged as odd.

This doesn't style the rows directly, just tags the odd rows.

Using CSS, you can now construct different styles for odd rows for
this table. If you want to have more than 1 table on a page, each with
a different style, then fine. Just use appropriate CSS rules.

tbody tr
{
background: url(bg_td1.jpg) repeat-x top;
}

tbody tr.odd
{
background: #FFF8E8 url(bg_td2.jpg) repeat-x;
}

for example, for all normal rows.

Add a #ID to that for specific tables, etc.

No JS. Minimal html.
-- 
-
Richard Quadling
Standing on the shoulders of some very clever giants!
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php