Jump to content

calculating total in a column(not from database)


changkkm

Recommended Posts

Hi, i've been working on this for the whole day and still cant find the solution. I wanted to calculate the total for 1 column. but i am not sure how the codes work. This is the situation i am in:

59635677.th.jpg

 

As you can see from the image, I wrote a code to calculate Qty. and display its total in the Total column. And now I am suppose to write another code to calculate the column's total and display it in Total Price.

 

I have a php file extension name cashier.php and the calculation is done in updatecashier.php.

 

 

Code in cashier.php

 

button to submit query, once click will link to the updatecashier.php to calculate the total. And display it back in cashier.php in the Total Price column.

 

<input type="submit" name="calculate" value="Calculate Total" />

 

<?php echo $_SESSION['priceTotal']; ?>

 

 

then in updatecashier.php

 

note that xxx is problem which i am not sure what i am missing either in cashier.php or updatecashier.php

 

if(isset($_POST['calculate'])){

$_SESSION['priceTotal'] = count($_SESSION['xxx']);

count($_SESSION['xxx']);

}

header("Location: http://localhost/cashier.php");

 

I am really stuck in this situation and hope sum 1 could help me solve this. thanks in advance

Why don't you just calculate the 'Total Price' whilst calculating the 'Total'?

 

Could you post some more code as what you've given us isn't really helpful...

 

Plus count() is used to display the length of an array. If you have all of the 'Total' amounts in an array, you might be able to use 'array_sum()'

 

http://uk3.php.net/array-sum

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.