Question : calculating balance from statement printout

I have this table below:

idinvoice             invoice           idpayment          payment     balance
442                      60.00             51                       60.00         0.00
441                     900.00                                                        900.00
440                     960.00            50                      200.00       760.00
438                     390.00            47                      100.00       190.00
                                                  49                      100.00

I need to calculate the totalbalance. Its way above me and I hope someone can help me please.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
<?php

/**
* @package LQM Component
* @subpackage Views
* @version $Id: dealership.html.php 328 2007-09-10 08:50:05Z tcp $
* @copyright Copyright (C) 2006 - 2007 Green Mountain Information Technology and Consulting. All rights reserved.
* @author [email protected]
*
* This is a sample file that demonstrates how to write a custom template that displays a single record
* Customize for more than one records.
*/


// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

static $prepared;

// Important objects
$dispatch = LQMDispatch::getInstance();
$query = $dispatch->getQuery();

// Load the JS and CSS files associated with the lead application
$this->loadJavaScript();
$this->loadStyleSheet();

// Include the header file
$this->includeHeaderFile();
?>
<div class="lqmResultMessage"><?php echo $this->getMessage() ?></div> 
<?php


// Sanity check - make sure that the query was configured correctly
if ( ! $query->expectsResults() )
{
throw new LQMException("The invoice template expects at least one record to be returned");
}

// Check if there are results to display
if ( $dispatch->hasResultsToDisplay() ) {

$result	= $dispatch->getCurrentResultSet();
	
	// We want the data from the first row, ie, index 0
	$result->setRowIndex(0);
	$name = $result->field('name');
	$reference = $result->field('reference');

	$nextRow =1;
	$j = 1;
	$n =1;
	WHILE ($nextRow) {         
            $idinvoice[$j]= $result->field('idinvoice');
            $invoice[$j] = $result->field('invoice');
            $amount[$j] = $result->field('amount');
            $idpayment[$j] = $result->field('idpayment');
            $cheque_no[$j] = $result->field('cheque_no');
            $pdatetime[$j] = $result->field('pdatetime');
            $username[$j] = $result->field('username');
			$balance[$j] = $result->field('balance');
            $n++;
			$j++;
			
            $nextRow = $result->nextRow();   
      }  


// for ($a=1;$a<=$j;$a++){$totalbalance = $totalbalance + $balance[$a];}

?>


<table width="725" border="0" cellspacing="0" cellpadding="0">
    <tr>
       <td width="391" rowspan="5">&nbsp;</td>
       <td width="74" rowspan="5"><img src="images/logo.jpg" alt="logo" width="72" height="73" /></td>
       <td width="260"><font size="2">RANACO EDUCATION</font></td>
    </tr>
    <tr>
       <td><font size="2">TRAINING INSTITUTE</font></td>
    </tr>
    <tr>
       <td><font size="2">KP(JPS)5195/IPTS/1239(2)</font></td>
    </tr>
    <tr>
       <td><font size="1"><i>(Wholly Owned By Ranaco Education </i></font></td>
    </tr>
    <tr>
       <td><font size="1"><i>Training Institute Sdn.Bhd. - 624541-A) </i></font></td>
    </tr>
</table>
<table width="725" border="0" cellspacing="0" cellpadding="0">
    <tr>
       <td>&nbsp;</td>
    </tr>
</table>
<table width="725" border="0" cellspacing="0" cellpadding="0">
    <tr>
       <td><br>
       <br></td>
    </tr>
</table>
<table width="725" border="0" cellspacing="0" cellpadding="0">
    <tr>
       <td><div align="center"><font size="3"><b>STATEMENT OF ACCOUNT </b></font></div></td>
    </tr>
</table>
<table width="725" border="0" cellspacing="0" cellpadding="0">
    <tr>
       <td>&nbsp;</td>
    </tr>
</table>
<table width="725" border="0" cellspacing="0" cellpadding="0">
    <tr>
       <td>&nbsp;</td>
    </tr>
</table>
<table width="725" border="0" cellspacing="0" cellpadding="0">
    <tr>
       <td width="90"><font size="2">NAME</font></td>
       <td width="635">: <font size="2"><?php echo strtoupper ($name);?></font></td>
    </tr>
</table>
<table width="725" border="0" cellspacing="0" cellpadding="0">
    <tr>
       <td width="90"><font size="2">REREFENCE</font></td>
       <td width="634">: <font size="2"><?php echo $reference;?></font></td>
    </tr>
</table>

<table width="725" border="0" cellspacing="0" cellpadding="0">
    <tr>
       <td>&nbsp;</td>
    </tr>
</table>
<table width="725" border="0" cellspacing="0" cellpadding="0">
    <tr>
       <td>&nbsp;</td>
    </tr>
</table>
<table width="650" border="0" cellspacing="0" cellpadding="0">
    <tr>
       <td width="119" bgcolor="#999999"><div align="center"><font size="2"><b>Invoice ID</b></font></div></td>
       <td width="135" bgcolor="#999999"><div align="center"><font size="2"><b>Invoice</b></font></div></td>
       <td width="123" bgcolor="#999999"><div align="center"><font size="2"><b>Amount (RM)</b></font></div></td>
       <td width="138" bgcolor="#999999"><div align="center"><font size="2"><b>Payment ID</b></font></div></td>
       <td width="135" bgcolor="#999999"><div align="right"><font size="2"><b>Cheque NO</b></font></div></td>
	   <td width="138" bgcolor="#999999"><div align="center"><font size="2"><b>Date</b></font></div></td>
       <td width="135" bgcolor="#999999"><div align="right"><font size="2"><b>Received By</b></font></div></td>
	   <td width="135" bgcolor="#999999"><div align="right"><font size="2"><b>Balance</b></font></div></td>
    </tr>
   
	
	<?php 
	
	for ($j=1;$j<$n;$j++)	{
    
	?>
    <tr>
	  <td><div align="center"><font size="2"><?php if($j > 1){
														if($idinvoice[$j - 1] == $idinvoice[$j]){
															echo '&nbsp;';
														}else{
															echo $idinvoice[$j];
														}
													}else{
														echo $idinvoice[$j];
													}?></font></div></td>
      <td><div align="center"><font size="2"><?php if($j > 1){
														if($idinvoice[$j - 1] == $idinvoice[$j]){
															echo '&nbsp;';
														}else{
															echo $invoice[$j];
														}
													}else{
														echo $invoice[$j];
													}?></font></div></td>
	  <td><div align="center"><font size="2"><?php echo $amount[$j];?></font></div></td>
      <td><div align="center"><font size="2"><?php echo $idpayment[$j]; ?></font></div></td>
      <td><div align="center"><font size="2"><?php echo $cheque_no[$j]; ?></font></div></td>
      <td><div align="right"><font size="2"><?php echo $pdatetime[$j];?></font></div></td>
	  <td><div align="right"><font size="2"><?php echo $username[$j];?></font></div></td>
	  <td><div align="right"><font size="2"><?php if($j > 1){
														if($balance[$j - 1] == $balance[$j]){
															echo '&nbsp;';
														}else{
															echo $balance[$j];
														}
													}else{
														echo $balance[$j];
													}?></font></div></td>
    </tr>
	<?php } ?>
</table>
	<?php } ?>

Answer : calculating balance from statement printout

The difference will be in your keyboard layout. You will be using French to type but your kb layout is English so it will take you some time to work out which key you need to press for certain French letters. Apart from that everything will be the same.
Random Solutions  
 
programming4us programming4us