fazz Posted December 17, 2007 Share Posted December 17, 2007 I have a shopping cart, and each client that logs on has a budget spend - am testing it with a budget of 5000. So I have created this that works until the toal goes past 999 <?php $Budget = $HTTP_GET_VARS['Budget']; $TotalCart = $HTTP_SESSION_VARS["icNamco"]->col("Total"); echo number_format ($Budget - $TotalCart); ?> It deducts and gives me the correct total until it goes over 999 and the reverts to displaying 4,999 Can any one shine any light on this! Merry christmas to everyone! Quote Link to comment Share on other sites More sharing options...
revraz Posted December 17, 2007 Share Posted December 17, 2007 What does the function number_format contain? And if you want your code to last more than a year or two, you should replace $HTTP_GET_VARS with $_GET, $HTTP_SESSION_VARS with $_SESSION Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted December 17, 2007 Share Posted December 17, 2007 What does the function number_format contain? It's a library function: http://php.net/number_format Quote Link to comment Share on other sites More sharing options...
fazz Posted December 17, 2007 Author Share Posted December 17, 2007 Being a php newbie how do I apply this? Quote Link to comment Share on other sites More sharing options...
fazz Posted December 17, 2007 Author Share Posted December 17, 2007 the number_format contains: ....."]->col("Total"); is the total from the shopping cart $Budget is a total from the database related to the customer who has logged on it is just a text field with 5000.00 entered in to it Quote Link to comment Share on other sites More sharing options...
fazz Posted December 17, 2007 Author Share Posted December 17, 2007 I have now found this and changed my code <?php //Add up toal items and - from Budget cost: does not work correctley over 999.00 $Budget = $HTTP_GET_VARS['Budget']; $TotalCart = $HTTP_SESSION_VARS["icNamco"]->col("Total"); $BudgetRemain = $Budget - $TotalCart; echo number_format ($BudgetRemain, 0, "", ","); ?> I now have a budget of 485 when I add a total of 595 into my cart it says the remaining budet is '-110' I add a second item of 415 and then the toal says £484 instead of - 594 I just can't seem to work it out? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.