BCAV_WEB Posted October 7, 2010 Share Posted October 7, 2010 Hi, I have a two parter question completely different. 1. I need to have two money figures saved to my database "RRP" and "our price" and with this I would like to work out the savings. Easy enough to do, however how do I get the int number to display as £4,567.00 for example? [ $savings = $row["rrp"] - $row["our_price"]; ] 2. Part two of my question I have a database that stores cars, so models makes etc... but I also need to store colours for each car, so the colour name and the colour colour. What would be the best way of doing this? Remembering that a single car can have many many colours. Any ideas and thought would be much appericated. Thank you Quote Link to comment https://forums.phpfreaks.com/topic/215345-dealing-with-money-in-mysql-joining-tables/ Share on other sites More sharing options...
fenway Posted October 7, 2010 Share Posted October 7, 2010 1. store proper DECIMAL fields, format on output only. 2. use a many-to-many relation table. Quote Link to comment https://forums.phpfreaks.com/topic/215345-dealing-with-money-in-mysql-joining-tables/#findComment-1119919 Share on other sites More sharing options...
BCAV_WEB Posted October 8, 2010 Author Share Posted October 8, 2010 But how do you do that? Quote Link to comment https://forums.phpfreaks.com/topic/215345-dealing-with-money-in-mysql-joining-tables/#findComment-1120117 Share on other sites More sharing options...
fenway Posted October 8, 2010 Share Posted October 8, 2010 Which one? Quote Link to comment https://forums.phpfreaks.com/topic/215345-dealing-with-money-in-mysql-joining-tables/#findComment-1120212 Share on other sites More sharing options...
BCAV_WEB Posted October 8, 2010 Author Share Posted October 8, 2010 Both how do you set the demical points in phpMyAdmin? And link two tables together? Quote Link to comment https://forums.phpfreaks.com/topic/215345-dealing-with-money-in-mysql-joining-tables/#findComment-1120218 Share on other sites More sharing options...
fenway Posted October 10, 2010 Share Posted October 10, 2010 The DECIMAL column type must be one of the options -- I've always used alter statements. As for linking them together, you'll need 3 tables -- colors, cars, and the relation table. Simply store a uid tuple in the latter. Quote Link to comment https://forums.phpfreaks.com/topic/215345-dealing-with-money-in-mysql-joining-tables/#findComment-1120792 Share on other sites More sharing options...
BCAV_WEB Posted October 11, 2010 Author Share Posted October 11, 2010 Okay, but how do you get the commas added in so "3000" would become "3,000" and maths would still be possible?? Quote Link to comment https://forums.phpfreaks.com/topic/215345-dealing-with-money-in-mysql-joining-tables/#findComment-1121006 Share on other sites More sharing options...
fenway Posted October 12, 2010 Share Posted October 12, 2010 Okay, but how do you get the commas added in so "3000" would become "3,000" and maths would still be possible?? That's formatting for output -- leave the raw numbers alone. Quote Link to comment https://forums.phpfreaks.com/topic/215345-dealing-with-money-in-mysql-joining-tables/#findComment-1121315 Share on other sites More sharing options...
WilliamC Posted October 12, 2010 Share Posted October 12, 2010 As fenway said, do not bother with formatting until after all the math you want to do is done, after that number_format() is your friend for display output. Quote Link to comment https://forums.phpfreaks.com/topic/215345-dealing-with-money-in-mysql-joining-tables/#findComment-1121387 Share on other sites More sharing options...
BCAV_WEB Posted October 12, 2010 Author Share Posted October 12, 2010 Okay, do you know anyway to formatt the outputted data? Quote Link to comment https://forums.phpfreaks.com/topic/215345-dealing-with-money-in-mysql-joining-tables/#findComment-1121399 Share on other sites More sharing options...
WilliamC Posted October 12, 2010 Share Posted October 12, 2010 I already told you that... number_format() Quote Link to comment https://forums.phpfreaks.com/topic/215345-dealing-with-money-in-mysql-joining-tables/#findComment-1121400 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.