[PHP] Brain Fart- table formatting help

2002-07-29 Thread Brian V Bonini

I'm having a total brain fart and can not seem to get the right logic for
this...

I'm trying to format the output of a db query with alternating row colors,
the thing is the usual
if ($i%2) {} will not work here because the alternating colors do not
necessarily fall on odd or even rows.

The one constant is that if ($row-show_title) is true the table row will
have a background color then I need to make the rows after that alternate
until if ($row-show_title) is true again.

Roughly I have the whole thing laid out like this right now:

echo table BORDER=\0\ CELLSPACING=\0\ CELLPADDING=\2\\n;
while($row = mysql_fetch_object($result)) {
if($row-show_company  $row-show_title  $row-show_month) {
display month;
} else if ($row-show_title) {
display title;
display first row with background color;
} else {
display rows with no background color; //right here needs to alternate
tr background color
}
}
echo /table;

I think I've been looking at his too long and I just have jello brain right
now but I just can't seem to straighten this out in my head...

Thanks for the help...

-B


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




RE: [PHP] Brain Fart- table formatting help

2002-07-29 Thread Jay Blanchard

[snip]
I'm trying to format the output of a db query with alternating row colors,
the thing is the usual
if ($i%2) {} will not work here because the alternating colors do not
necessarily fall on odd or even rows.
[/snip]

?php
$i = 0;
while($exrows = mysql_fetch_object($dbcdrex)){
$bgcolor = ($i++  1) ? '#FF' : '#CC';
//other table stuff
?

HTH!

Jay

Minds are like parachutesÂ…they only function when OPEN

*
* Want to meet other PHP developers *
* in your area? Check out:  *
* http://php.meetup.com/*
* No developer is an island ... *
*

***
* *
* Texas PHP Developers Meeting*
* Spring 2003 *
* T Bar M Resort  Conference Center  *
* New Braunfels, Texas*
* Interested? Contact;*
* [EMAIL PROTECTED] *
* *
***



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




RE: [PHP] Brain Fart- table formatting help

2002-07-29 Thread Brian V Bonini

Isn't that the same thing essentially? See, from the time ($row-show_title)
is true until it is true again is not a fixed number so the only constant is
that if ($row-show_title) is true then the tr background color will be
on. Then I need to alternate the background color between on and off until
($row-show_title) is true again. Then start the process over. So I'm sure
my ignorance has prevented me from fully understanding what you tried to
show me below but isn't that the same as saying:
if ($i1) {
 do this;
} else {
 do this;
}
which is the same as if ($i%2) { etc. }

???

-B

 -Original Message-
 From: Jay Blanchard [mailto:[EMAIL PROTECTED]]
 Sent: Monday, July 29, 2002 9:19 AM
 To: 'Brian V Bonini'; [EMAIL PROTECTED]
 Subject: RE: [PHP] Brain Fart- table formatting help


 [snip]
 I'm trying to format the output of a db query with alternating row colors,
 the thing is the usual
 if ($i%2) {} will not work here because the alternating colors do not
 necessarily fall on odd or even rows.
 [/snip]

 ?php
 $i = 0;
 while($exrows = mysql_fetch_object($dbcdrex)){
   $bgcolor = ($i++  1) ? '#FF' : '#CC';
 //other table stuff
 ?

 HTH!

 Jay

 Minds are like parachutesÂ…they only function when OPEN

 *
 * Want to meet other PHP developers *
 * in your area? Check out:  *
 * http://php.meetup.com/*
 * No developer is an island ... *
 *

 ***
 * *
 * Texas PHP Developers Meeting*
 * Spring 2003 *
 * T Bar M Resort  Conference Center  *
 * New Braunfels, Texas*
 * Interested? Contact;*
 * [EMAIL PROTECTED] *
 * *
 ***




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




RE: [PHP] Brain Fart- table formatting help

2002-07-29 Thread Jay Blanchard

[snip]
Isn't that the same thing essentially? See, from the time ($row-show_title)
is true until it is true again is not a fixed number so the only constant is
that if ($row-show_title) is true then the tr background color will be
on. Then I need to alternate the background color between on and off until
($row-show_title) is true again. Then start the process over. So I'm sure
my ignorance has prevented me from fully understanding what you tried to
show me below but isn't that the same as saying:
if ($i1) {
 do this;
} else {
 do this;
}
which is the same as if ($i%2) { etc. }
[/snip]

Ah, well... that was not clearly explained in your first post. You wanted
alternating rows colors, and that is what I gave you. Let's see if I
understand the question;

For each show_title there are multiple rows of data, but they do not match
row counts from show to show?
You want the alternating colors to begin with each show_title, in other
words the row with the show_title in it shall always be gray, while others
rows alternate between white and gray?

Jay

Madness takes its toll-please have exact change

*
* Want to meet other PHP developers *
* in your area? Check out:  *
* http://php.meetup.com/*
* No developer is an island ... *
*

***
* *
* Texas PHP Developers Meeting*
* Spring 2003 *
* T Bar M Resort  Conference Center  *
* New Braunfels, Texas*
* Interested? Contact;*
* [EMAIL PROTECTED] *
* *
***



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




Re: [PHP] Brain Fart- table formatting help

2002-07-29 Thread 1LT John W. Holmes

So only increase $i when $row-show_title is true.

if($row-show_title) { $i++; }
$bgcolor = ($i  1) ? '#FF' : '#CC';

---John Holmes...

- Original Message -
From: Brian V Bonini [EMAIL PROTECTED]
To: Jay Blanchard [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Monday, July 29, 2002 10:26 AM
Subject: RE: [PHP] Brain Fart- table formatting help


 Isn't that the same thing essentially? See, from the time
($row-show_title)
 is true until it is true again is not a fixed number so the only constant
is
 that if ($row-show_title) is true then the tr background color will be
 on. Then I need to alternate the background color between on and off until
 ($row-show_title) is true again. Then start the process over. So I'm sure
 my ignorance has prevented me from fully understanding what you tried to
 show me below but isn't that the same as saying:
 if ($i1) {
  do this;
 } else {
  do this;
 }
 which is the same as if ($i%2) { etc. }

 ???

 -B

  -Original Message-
  From: Jay Blanchard [mailto:[EMAIL PROTECTED]]
  Sent: Monday, July 29, 2002 9:19 AM
  To: 'Brian V Bonini'; [EMAIL PROTECTED]
  Subject: RE: [PHP] Brain Fart- table formatting help
 
 
  [snip]
  I'm trying to format the output of a db query with alternating row
colors,
  the thing is the usual
  if ($i%2) {} will not work here because the alternating colors do not
  necessarily fall on odd or even rows.
  [/snip]
 
  ?php
  $i = 0;
  while($exrows = mysql_fetch_object($dbcdrex)){
  $bgcolor = ($i++  1) ? '#FF' : '#CC';
  //other table stuff
  ?
 
  HTH!
 
  Jay
 
  Minds are like parachutes.they only function when OPEN
 
  *
  * Want to meet other PHP developers *
  * in your area? Check out:  *
  * http://php.meetup.com/*
  * No developer is an island ... *
  *
 
  ***
  * *
  * Texas PHP Developers Meeting*
  * Spring 2003 *
  * T Bar M Resort  Conference Center  *
  * New Braunfels, Texas*
  * Interested? Contact;*
  * [EMAIL PROTECTED] *
  * *
  ***
 
 


 --
 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] Brain Fart- table formatting help

2002-07-29 Thread Brian V Bonini

 Ah, well... that was not clearly explained in your first post. You wanted
 alternating rows colors, and that is what I gave you. Let's see if I
 understand the question;

 For each show_title there are multiple rows of data, but they do not match
 row counts from show to show?
 You want the alternating colors to begin with each show_title, in other
 words the row with the show_title in it shall always be gray, while others
 rows alternate between white and gray?


Sorry, I thougth I had explained it better.. But, yes, you have explained it
well now...


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