0

Hi guys,

Probably this is something really over discuss but would you be so kind to teach me.

I want to store prices on MySQL table, i currently have my Data Type as FLOAT with my prices on the table but it renders only the same number, what is the right Data Type for currency dollars or $ symbol.

Thank you so much

2
Contributors
6
Replies
7
Views
9 Years
Discussion Span
Last Post by ocbphoto
0

use DECIMAL
you may not necessarily see it at first, but float uses a non exact number and decimal uses exact

the currency symbol is just a matter of display, add it to your code side instead of db side

0

thank you dickersonka, but one last question is there a way to have this number being display dynamically with the currency symbol?

So i will only put numbers in my DB with decimals and when it renders will show it in my site with the $ symbol, without coding on a side

0

yes

remember though, you can't do calculations with it, you might want to pull back the real value, and with a symbol

select columnName, concat('$', columnName) as  amount from tableName;
0

I am not very sure where to insert the concat function, here is my code, thank you

<?php echo $row_rsMotoDetail['product_model']; ?><br />
$<?php echo $row_rsMotoDetail['price']; ?>
0

use it in the select statement, not the output

why don't you just add the '$' in front of your row right here?

0

something like this?? is this correct? i am a newbie but a fast learner

$<?php echo $row_rsMotoDetail['$', 'price']; ?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.