Please help me to insert sum total into IHTML PAGE.

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Please help me to insert sum total into IHTML PAGE.
free69
CZ Newbie
free69 has been a member for over 20 year's 20 Year Member
Status: Offline
Joined: Dec 02, 2003
0.00 posts per day
Posts: 5
Points: 260
   
Hello,
I want to insert total column into the bottom of the page quoted hereunder.
I made it like


<tr>
<?php $bgcolor="#00ff00" ?>
<tr width="15%" BGCOLOR=<?php echo $bgcolor ?>>
<td></td>
<td></td>
<td width="15%"></td>
<td colspan="4">TOTAL</td>
<td></td>
<td align=right with="150" ><?php
$sum_total +=$total;
★ echo number_format($sum_total)."₩&nbsp";
?>
</td>
</tr>

However, ★ displays just total of the last line. How can I make this show sum totals of all the totals above?
The sample page is linked to : [ Register or login to view links on this board.]





<?php
search_header($order_list_lbl, $modulename, "order_list");
?>
<center>
<?php
// PAVLO: 9.12.00
$navi_db = new ps_DB;
$q = "SELECT order_status_code, order_status_name ";
$q .= "FROM order_status WHERE vendor_id = $ps_vendor_id";
$navi_db->query($q);
while ($navi_db->next_record()) {
$url = SECUREURL . "?page=$modulename/order_list&show=";
$url .= $navi_db->f("order_status_code");
echo "<A HREF=".$sess->url($url).">";
echo $navi_db->f("order_status_name")."
</A> | ";
}
$url = SECUREURL . "?page=$modulename/order_list&show=";
echo "<A HREF=".$sess->url($url).">TOTAL LIST</A>";
?>
</center><BR>
<?php
// Enable the multi-page search result display
if (empty($offset))
$offset=0;
if ($keyword) {
$list = "SELECT order_id,orders.cdate,orders.mdate,order_subtotal,";
$list .= "order_tax, order_shipping, order_shipping_tax,";
$list .= "order_status,username,last_name,ip FROM orders, user_info, auth_user_md5 WHERE ";
$count = "SELECT count(*) as num_rows FROM orders, user_info, auth_user_md5 WHERE ";
$q = "(orders.order_id LIKE '%$keyword%' ";
$q .= "OR orders.order_status LIKE '%$keyword%' ";
$q .= "OR auth_user_md5.username LIKE '%$keyword%' ";
$q .= "OR user_info.last_name LIKE '%$keyword%' ";
$q .= ") ";
$q .= "AND orders.user_id=auth_user_md5.user_id ";
$q .= "AND user_info.user_id=auth_user_md5.user_id ";
$q .= "AND user_info.user_info_id=orders.user_info_id ";
$q .= "AND orders.vendor_id='$ps_vendor_id' ";
$q .= "ORDER BY orders.cdate DESC ";
$list .= $q . " LIMIT $offset, " . SEARCH_ROWS;
$count .= $q;
}
else
{
$q = "";
$list = "SELECT order_id,orders.cdate,orders.mdate,order_subtotal,";
$list .= "order_tax, order_shipping, order_shipping_tax,";
$list .= "order_status,username,last_name,ip FROM orders, user_info, auth_user_md5 WHERE ";
$count = "SELECT count(*) as num_rows FROM orders, user_info, auth_user_md5 WHERE ";
$q .= "orders.user_id=auth_user_md5.user_id ";
$q .= "AND user_info.user_id=auth_user_md5.user_id ";
$q .= "AND orders.vendor_id='$ps_vendor_id' ";
$q .= "AND user_info.user_info_id=orders.user_info_id ";
if ($show)
$q .= "AND order_status = '$show' ";
$q .= "ORDER BY orders.cdate DESC ";
$list .= $q . " LIMIT $offset, " . SEARCH_ROWS;
$count .= $q;
}
$db->query($count);
$db->next_record();
$num_rows = $db->f("num_rows");
if ($num_rows == 0) {
echo "No such word!<BR>";
}
else {
?>
<table width="100%" border="0" cellspacing="0" cellpadding="2" align="left" NOWRAP>
<tr>
<td NOWRAP><?php echo $order_list_id ?></td>
<td NOWRAP><?php echo $order_list_username ?></td>
<td NOWRAP><?php echo $order_list_last_name ?></td>
<td NOWRAP><?php echo $order_list_ip ?></td>
<td NOWRAP><?php echo $order_list_cdate ?></td>
<td NOWRAP><?php echo $order_list_mdate ?></td>
<td NORWAP><?php echo $order_list_status ?></td>
<?php
// ADDED THE TABLE DELETE AT THE TOP
if ($perm->check("admin")) {
?>
<td NORWAP><?php echo $order_list_delete ?></td>
<?php
}
// ENDED THE TABLE DELETE AT THE TOP
?>
<td align="right" NOWRAP><?php echo $order_list_total."&nbsp" ?></td>
</tr>
<?php
$db->query($list);
$i = 0;
while ($db->next_record()) {
if ($i++ % 2)
$bgcolor=SEARCH_COLOR_1;
else
$bgcolor=SEARCH_COLOR_2;
?>
<tr width="100%" BGCOLOR=<?php echo $bgcolor ?> >
<td><?php
$url = SECUREURL . "?page=$modulename/order_print&order_id=";
$url .= $db->f("order_id");
echo "<A HREF=" . $sess->url($url) . ">";
printf("%05d", $db->f("order_id"));
echo "</A><BR>";
?></td>
<?php
if ($perm->check("admin")) {
?>
<td NOWRAP><?php
echo $db->f("username");
?></td>
<td NOWRAP><?php
echo $db->f("last_name");
}
?></td>
<td NOWRAP><?php
echo $db->f("ip");
?></td>
<td NOWRAP><?php
setlocale(LC_TIME,strtolower($lang)."_".$lang);
echo strftime("%Y-%m-%d<br>%H:%M", $db->f("cdate"));
?></td>
<td NOWRAP><?php
setlocale(LC_TIME,strtolower($lang)."_".$lang);
echo strftime("%Y-%m-%d<br>%H:%M", $db->f("mdate"));
?></td>
<td NOWRAP><?php
$q = "SELECT order_status_name FROM order_status WHERE ";
$q .= "order_status_code = '" . $db->f("order_status") . "'";
$dbos = new ps_DB;
$dbos->query($q);
$dbos->next_record();
?>
<form method="post" action="<?php echo SECUREURL ?>"><?php
$ps_order_status->list_order_status($db->f("order_status"));
$sess->hidden_session();?>
<input type="submit" name="Submit" value="update">
<input type="hidden" name="page" value="order/order_list">
<input type="hidden" name="func" value="orderStatusSet">
<input type="hidden" name="order_id" value="<?php echo $db->f("order_id") ?>">
</form></td>
<!-- ADDED TO DLEETE RECORD AFTER CHECKING ADMIN PERMISSION -->
<?php
if ($perm->check("admin")) {
?>
<td>
<form method="post" action="<?php $sess->purl(SECUREURL . "?page=order/order_list&func=orderDelete&order_id=".$db->f("order_id")); ?>">
<input type="submit" name="Delete" value="delete">
<input type="hidden" name="page" value="order/order_list">
<input type="hidden" name="func" value="orderDelete">
<input type="hidden" name="order_id" value="<?php echo $db->f("order_id") ?>">
</form>
</td>
<?php
}
?>
<!-- END OF THE DELETE ORDER FUNCTION -->
<td align=right with="150" ><?php
// Calculate order total
$subtotal = $db->f("order_subtotal");
$rate = $db->f("order_tax");
$shipping= $db->f("order_shipping");
$shipping_tax= $db->f("order_shipping_Tax");
$total = $subtotal + $rate + $shipping + $shipping_tax;
★echo number_format($total)."₩&nbsp";
?>
</td></tr>

<?php
}
?>
<tr>
<?php $bgcolor="#00ff00" ?>
<tr width="15%" BGCOLOR=<?php echo $bgcolor ?>>
<td></td>
<td></td>
<td width="15%"></td>
<td colspan="4">TOTAL :</td>
<td></td>
<td align=right with="150" ><?php
$sum_total +=$total;
★ echo number_format($sum_total)."원&nbsp";
?>
</td>
</tr>
</tr>
</table>
<?php
search_footer($modulename, "order_list", $offset, $num_rows, $keyword);
}
?>



Back to top Reply with quote
#2   
Telli
Site Admin
Telli has been a member for over 20 year's 20 Year Member
Occupation: Self Employed
Age: 45
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.06 posts per day
Posts: 8089
Points: 494,430
   
Try changing $sumtotal+=$total; to $sumtotal++=$total;

See if that doesnt add them up.

Telli




_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
#3   
free69
CZ Newbie
free69 has been a member for over 20 year's 20 Year Member
Status: Offline
Joined: Dec 02, 2003
0.00 posts per day
Posts: 5
Points: 260
   
Thanks.
In that case, I have parse error.
Would you try in another way?



Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum