Re: [PHP-DB] calculations using variables in html table cell

2003-12-03 Thread Ignatius Reilly
If you have to build complex, dynamic tables, do yourself a favour and use a
class that will allow you to feed directly arrays of numbers.
I use PEAR HTML_Table, which is great and easy to use.
You will have recouped the investment of learning the class after about one
hour.

HTH
Ignatius
_
- Original Message -
From: "Christopher Adams" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, December 03, 2003 21:07
Subject: [PHP-DB] calculations using variables in html table cell


> I am generating html tables dynamically. Each table has multiple columns
> and various calculations need to be done on each column and displayed
> at the bottom of the column. I am including the code from one table below.
> The $tablerow generates the table data and the $tablefooter generates the
> rows at the bottom that will include the calculated values.
>
> Preceding the $tablerow declaration, I have declared some variables and
done
> calculations. I then included these
> in the $tablefooter to display the calculated values. This works fine.
> However, I have many other calculations on other columns in other tables.
> Using this method, I would have to declare many new variables just for
> calculations.
>
>
> I am wondering if there is a way to do these calculations directly in the
> table cells. I am pretty new to PHP and have not used calculations much.
>
> $sumpop += $POP;
> $sumadultcirc += $ADULTCIRC;
> $sumjuvcirc += $JUVCIRC;
>
> $tablerow[1] = "" . $row["name"] . "" .
> "$POP$ADULTCIRC
>
$JUVCIRC$TOTCIRC$CIRCPERCAP$TOTREF$R
> EFPERCAP";
>
>
> $tablefooter[1] = "Table total$sumpop
>
$sumadultcirc$sumjuvcirc$TOTCIRC<
> /td>
>
$CIRCPERCAP$TOTREF$refpercap
> 
> Table average or per capita$POPAV
>
$ADCIRCAV$JUDCIRCAV$TOTCIRCAV >
> $CIRCPERAV$TOTREFAV$REPERAV";
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



[PHP-DB] calculations using variables in html table cell

2003-12-03 Thread Christopher Adams
I am generating html tables dynamically. Each table has multiple columns
and various calculations need to be done on each column and displayed
at the bottom of the column. I am including the code from one table below.
The $tablerow generates the table data and the $tablefooter generates the
rows at the bottom that will include the calculated values.

Preceding the $tablerow declaration, I have declared some variables and done
calculations. I then included these
in the $tablefooter to display the calculated values. This works fine.
However, I have many other calculations on other columns in other tables.
Using this method, I would have to declare many new variables just for
calculations.


I am wondering if there is a way to do these calculations directly in the
table cells. I am pretty new to PHP and have not used calculations much.

$sumpop += $POP;
$sumadultcirc += $ADULTCIRC;
$sumjuvcirc += $JUVCIRC;

$tablerow[1] = "" . $row["name"] . "" .
"$POP$ADULTCIRC
$JUVCIRC$TOTCIRC$CIRCPERCAP$TOTREF$R
EFPERCAP";


$tablefooter[1] = "Table total$sumpop
$sumadultcirc$sumjuvcirc$TOTCIRC<
/td>
$CIRCPERCAP$TOTREF$refpercap

Table average or per capita$POPAV
$ADCIRCAV$JUDCIRCAV$TOTCIRCAV
$CIRCPERAV$TOTREFAV$REPERAV";

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