i have a field in the db that is set to 'float' which holds a price, but when you enter say 444.50.... it saves it as 444.5 and therefore displays on the page as 444.5.
Do i need to change the field type to something else? or can i just rewrite this below so it shows 2 decimals, if so how?
<?php echo $row_jobs['price']; ?>
<?php echo number_format($row_jobs['price'],2); ?>
that's all it was, i feel so bad now
No problem, number_format is also a great tool to format numbers which are higher than 999.. for example:
$price = 5000;
echo $price; // this shows 5000
echo number_format($price); // this shows 5,000 with the comma
just a word of caution, FLOAT is an approximate datatype
if your prices always need to be accurate to the penny, be aware that with FLOAT you run the risk of inaccuracy in calculations
use DECIMAL instead