0

I am changed data-type of 1 table field int to float for accept decimal values also

i am saving value as 0.05, 0.1

when i am fetching value with following query:

SELECT points from tbl_points where user_id=10

it returns me vaule like

0.0546565749

i am not getting why this is happening. i just want to display value as it saved to into table. i.e. 0.05 OR 0.1

please help me....

thanks in advance

5
  • 1
    what is datatype of your this value field in database? Commented Feb 11, 2014 at 5:40
  • What is the insert query you used ? And you can use the ROUND function. Commented Feb 11, 2014 at 5:40
  • @DhruvPathak no round will make that 0 Commented Feb 11, 2014 at 5:41
  • @Vickey, not it does not, try SELECT ROUND(0.0546565749,2); Commented Feb 11, 2014 at 5:44
  • @DhruvPathak yes its the proper format Commented Feb 11, 2014 at 5:45

2 Answers 2

1

You need to change your float to 2 decimal places i.e. float(10,2)

Sign up to request clarification or add additional context in comments.

Comments

0
$tt = "105";
echo number_format((float)$tt, 2, '.', '');  // this will  output  105.00

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.