dflow Posted January 10, 2010 Share Posted January 10, 2010 this code echoes correctly the sum but the inserted result is 0?? <?php $TotalNumberAdults=$_POST['TotalNumberAdults']; $TotalNumberChildren=$_POST['TotalNumberChildren']; $TotalNumber=($TotalNumberAdults + $TotalNumberChildren); ?><?php echo sprintf($TotalNumber);?> <input name="TotalNumber" type="hidden" value="<?php echo sprintf($TotalNumber);?>" size="7"> Quote Link to comment https://forums.phpfreaks.com/topic/187941-php-calculate/ Share on other sites More sharing options...
MidOhioIT Posted January 10, 2010 Share Posted January 10, 2010 when you say your inserted result is 0, do you mean into a database? If so can I see your sql statements? Quote Link to comment https://forums.phpfreaks.com/topic/187941-php-calculate/#findComment-992297 Share on other sites More sharing options...
daneth1712 Posted January 10, 2010 Share Posted January 10, 2010 I am confused, when I test your code and change your post to a value of 2 for each the adults and children, I get a result of 4 for both the echo and the insert in your form. Looks fine to me. Quote Link to comment https://forums.phpfreaks.com/topic/187941-php-calculate/#findComment-992299 Share on other sites More sharing options...
ignace Posted January 10, 2010 Share Posted January 10, 2010 Read the manual on how to properly utilize sprintf echo sprintf('%d', $TotalNumber); Quote Link to comment https://forums.phpfreaks.com/topic/187941-php-calculate/#findComment-992307 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.