Re: Keeping data from while

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Brad Ciszewski a écrit :

I am writing a web script where the background colors of certain rows change
when the amount of money changes.
For example, my first piece of data is 1.12. my second piece of data is
1.34, my third piece of data is 1.34, and my forth piece of data is 1.5.
They would like this on the webpage.
1.12 [light color]
1.34 [dark color]
1.34 [dark color]
1.5 [light color]
As you can see, when the amount of cash changes, the background color
changes.
What I am trying to do is figure out how to keep the old data from my last
while statement.

How can I do this? Any help is greatly appreciated.
That's really simple. Just keep track of the last data :

$last_data = 0;
$light_color=true;
while (...)
{
   if ($data != $last_data)
   {
      $last_data = $data;
      $light_color = !$light_color;
   }
   if ($light_color)
      echo "<font color=#eeeeee>.....";
   else
      echo "<font color=#444444>.....";
}

Something like this....

--

Alain -- http://www.vivahate.org

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux