[snip]
> Challenge; Can this be made as simple for rows too?

<thinking out loud :-)>

  <?php

    $rowTotals = array ();

    while ($row = mysql_fetch_object($result)) {
      $rowTotal = 0;
      foreach ($row as $key=>$val)
        $rowTotal += $val;
      // display whatever is needed from $row
      $rowTotals[] = $rowTotal; // or echo it out to the last column of the
table
    }

  ?>

</tol>
[/snip]

:^]

Or based on the original query;

while($row = mysql_fetch_object($result)){
   print("<td>" . $row->value . "</td>\n");
   print("<td>" . $row->another_value . "</td>\n");
   $value1 = $value1 + $row->value;
   $value2 = $value2 + $row->another_value;
   }

you could add the following to the WHILE loop ...
   print("<td>" . ($row->value + $row->another_value) . "</td>\n");

... giving you another column with the row total. That way you could avoid
adding columns that do not contain numerical values if that is the case in
your result set. And I think that you would want to use mysql_fetch_array
for your example.

Jay



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

Reply via email to