Hello all.
I have a form that users are able to enter dollar amounts for each month and add them to the table. i am having difficulty adding cells that display the totals. For example, rows have 12 columns(one for each month) I would like to have a 13th that totals the entire row. Also at the bottom of the table, i need to have a total for only that column. I hope this makes sense. Below is the code for one of the tables.
[code=php]
// income
$_SESSION["a$CDID"]['pl']['income']['0'] = '';
if (isset($_POST['iicomp']))
{
$mkey = $_POST['iicomp'];
$istate = $_POST['completed'];
}
if (isset($_GET['idel']))
{
unset($_SESSION["a$CDID"]['pl']['income'][$_GET['idel']]);
foreach ($_SESSION["a$CDID"]['pl']['income'] as $line)
$tmp[] = $line;
$_SESSION["a$CDID"]['pl']['income'] = $tmp;
}
if (isset($_POST['income']))
{
if (!empty($_POST['key']))
$_SESSION["a$CDID"]['pl']['income'][$_POST['key']] = $_POST['income'];
else
$_SESSION["a$CDID"]['pl']['income'][] = $_POST['income'];
}
if (count($_SESSIO N["a$CDID"]['pl']['income']) > '1')
{
foreach ($_SESSION["a$CDID"]['pl']['income'] as $key => $val)
{
if ($key != '0')
$PRINT_INCOME .= '
<tr class="input" '.$istyle.'><td >'.$key.'. '.$val['descript'].'</td><td>'.$val['jan'].'</td><td>'.$val['feb'].'</td>
<td>'.$val['mar'].'</td><td>'.$val['apr'].'</td><td>'.$val['may'].'</td><td>'.$val['jun'].'</td><td>'.$val['jul'].'</td><td>'.$val['aug'].'</td><td>'.$val['sep'].'</td><td>'.$val['oct'].'</td><td>'.$val['nov'].'</td><td>'.$val['dec'].'</td>
<td>"this is where I have been trying to insert a Sum for the row"</td>
<td align="center"> <a href="pl.php?cd id='.$CDID.'&ie dit='.$key.'">< input type="image" src="icon-blue-check.gif"</a></td><td><a href="pl.php?cd id='.$CDID.'&id el='.$key.'"><i nput type="image" src="icon-red-minus.gif"</a></td></tr>';
}
}
else
$PRINT_INCOME = '<tr class="row"><td ></td></tr>';
if (isset($_GET['iedit']))
[/code]
The code for displaying the row is
[code=php]
<?PHP if (isset($PRINT_I NCOME)) echo $PRINT_INCOME; ?>
[/code]
Thankyou
I have a form that users are able to enter dollar amounts for each month and add them to the table. i am having difficulty adding cells that display the totals. For example, rows have 12 columns(one for each month) I would like to have a 13th that totals the entire row. Also at the bottom of the table, i need to have a total for only that column. I hope this makes sense. Below is the code for one of the tables.
[code=php]
// income
$_SESSION["a$CDID"]['pl']['income']['0'] = '';
if (isset($_POST['iicomp']))
{
$mkey = $_POST['iicomp'];
$istate = $_POST['completed'];
}
if (isset($_GET['idel']))
{
unset($_SESSION["a$CDID"]['pl']['income'][$_GET['idel']]);
foreach ($_SESSION["a$CDID"]['pl']['income'] as $line)
$tmp[] = $line;
$_SESSION["a$CDID"]['pl']['income'] = $tmp;
}
if (isset($_POST['income']))
{
if (!empty($_POST['key']))
$_SESSION["a$CDID"]['pl']['income'][$_POST['key']] = $_POST['income'];
else
$_SESSION["a$CDID"]['pl']['income'][] = $_POST['income'];
}
if (count($_SESSIO N["a$CDID"]['pl']['income']) > '1')
{
foreach ($_SESSION["a$CDID"]['pl']['income'] as $key => $val)
{
if ($key != '0')
$PRINT_INCOME .= '
<tr class="input" '.$istyle.'><td >'.$key.'. '.$val['descript'].'</td><td>'.$val['jan'].'</td><td>'.$val['feb'].'</td>
<td>'.$val['mar'].'</td><td>'.$val['apr'].'</td><td>'.$val['may'].'</td><td>'.$val['jun'].'</td><td>'.$val['jul'].'</td><td>'.$val['aug'].'</td><td>'.$val['sep'].'</td><td>'.$val['oct'].'</td><td>'.$val['nov'].'</td><td>'.$val['dec'].'</td>
<td>"this is where I have been trying to insert a Sum for the row"</td>
<td align="center"> <a href="pl.php?cd id='.$CDID.'&ie dit='.$key.'">< input type="image" src="icon-blue-check.gif"</a></td><td><a href="pl.php?cd id='.$CDID.'&id el='.$key.'"><i nput type="image" src="icon-red-minus.gif"</a></td></tr>';
}
}
else
$PRINT_INCOME = '<tr class="row"><td ></td></tr>';
if (isset($_GET['iedit']))
[/code]
The code for displaying the row is
[code=php]
<?PHP if (isset($PRINT_I NCOME)) echo $PRINT_INCOME; ?>
[/code]
Thankyou
Comment