I know this isn't solving your problem, but here is how I do it:

class RowAlternator
{
  private $on;
  private $off;
  private $state;

  function RowAlternator($on = "On", $off = "Off")
  {
    $this->on = $on;
    $this->off = $off;
  }

  function switchState()
  {
    $this->state = !$this->state;
  }

  function Next()
  {
    $this->switchState();
    return $this->Current();
  }

  function Current()
  {
    if ($this->state)
      return $this->on;
    return $this->off;
  }
}

then...

using CSS style attributes:

$row = new RowAlternator("background-color: #EDEDED;", "background-color:
#FFFFFF;");
$i = 10;
while ($i--)
{
  echo "<tr style='" . $row->Next() . "'><td>Hello</td></tr>";
}

or using CSS Class definitions

$row = new RowAlternator();
$i = 10;
while ($i--)
{
  echo "<tr class='" . $row->Next() . "'><td>Hello</td></tr>";
}


as far as dynamically calling functions in echo.. why not do this:

$row = 'row_color';
echo sprintf('%s<br />%s<br />%s', $row(), $row(), $row());

or something

btw, defining parameters like so: &o=null

only works in PHP 5.



"Jay Blanchard" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
[snip]
Well that could work, but i want to re call it every time it finds the
occurance of $row

if you said $row = row_color();
then echo "$row<br>$row<br>$row";

it would output the content of $row1 three times.
Because $row =row_color calls it, defines the returned value of row_color as
the contents of it, and never calls it again. I need it to dynamicly call it
every time around.
[/snip]

Top posting == bad
replying off list == bad

Then loop through the rows with either a for loop or while loop.

while(TRUE === $row){
   echo row_color($row) . "<br>";
}

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

Reply via email to