changkkm Posted March 7, 2009 Share Posted March 7, 2009 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: 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 Link to comment https://forums.phpfreaks.com/topic/148340-calculating-total-in-a-columnnot-from-database/ Share on other sites More sharing options...
Mikedean Posted March 7, 2009 Share Posted March 7, 2009 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 Link to comment https://forums.phpfreaks.com/topic/148340-calculating-total-in-a-columnnot-from-database/#findComment-778798 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.