dflow Posted November 25, 2009 Share Posted November 25, 2009 i have an AVG result it is echoed fine with the decimal point and i want it to be inserted as a double: ($_POST['AVGrating'], "double"), and set in the db as a double but the inserted value in the db is rounded down for example 3.80 is 3.00 any ideas? Quote Link to comment Share on other sites More sharing options...
Goldeneye Posted November 25, 2009 Share Posted November 25, 2009 Look at the round function in the PHP Manual. Try round($_POST['AVGrating'], 2) Quote Link to comment Share on other sites More sharing options...
dflow Posted November 25, 2009 Author Share Posted November 25, 2009 Look at the round function in the PHP Manual. Try round($_POST['AVGrating'], 2) thanks but i dont want it rounded <input type="hidden" name="AVGrating" value="<?php echo sprintf($total); ?>" /> Quote Link to comment Share on other sites More sharing options...
Goldeneye Posted November 25, 2009 Share Posted November 25, 2009 PHP automatically rounds decimal numbers to whole-numbers. So you have to use the round function to set how many significant digits you want. Quote Link to comment Share on other sites More sharing options...
dflow Posted November 25, 2009 Author Share Posted November 25, 2009 not working Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted November 25, 2009 Share Posted November 25, 2009 PHP automatically rounds decimal numbers to whole-numbers. Only in certain contexts. @dflow, you're going to need to show us more code that is relevant to your problem. We need to know how the value is created (or where it's coming from) and see how you're trying to insert it into your database. We'd also need to know the table structure for the table you're inserting into. 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.