Welcome Guest, Not a member yet? Register   Sign In
Database Decimal Value

I'm storing some numeric data which will usually be whole numbers, but on a few occassions it may be a decimal.

At the moment i have the DB field set to 'Decimal(5,2)'

When i display the values on my page it always shows the decimal, but if its a whole number i would prefer it just to display as a whole number without the deciaml places...

72 should display as 72 not 72.00
72.35 should display as 72.35

is there a way to achieve this whilst still using a numeric data type, i'm quite happy to change the datatype to INT / FLOAT etc if needed.

Otherwise i thought perhaps it would be best just to have the datatype as varchar - as it stands i can't see any numeric opperations being required on the values as they are just final scores from golf competitions... but equally i don't want to rule out the ability if i don't have to.




Thanks matt but i don't think thats what i'm looking for... i don't want anything to be rounded up or down, i just don't want to display the .00 if a number is 73.00 for example - if its 73.01 then it should display as 73.01.

what i'm looking for is a way to omit .00 and only .00 i guess

$int = '6.00';
echo floor($int);

(I'm in Leeds by the way, hello!)

Thanks Matt, yeah i'm not too far from Leeds - good to see there's some locals on here too!

Theme © iAndrew 2016 - Forum software by © MyBB