stevenhu — 2011-02-02T19:08:39-05:00 — #1
I need to add a field where someone can add a fraction, like 1/5 or 2/15. Later, those fields will be added up, and I'll need to give the sum total as a decimal.
What's the correct way to make the field so I can add up the figures in PHP in decimal format? Should the field be of type varchar to accommodate the fraction, then I'll look for a PHP script on adding fractions and converting to decimal?
r937 — 2011-02-02T19:35:48-05:00 — #2
my suggestion is if you really require actual fractions to be accepted, that you at least validate and process them on input (regardless of whether the form field on the web page is a text box, dropdown, or whatever) and then store them as decimal values (not float)
stevenhu — 2011-02-03T10:26:07-05:00 — #3
So they need to be decimal values in order to add them together? I was thinking that I should do something like:
r937 — 2011-02-03T10:32:15-05:00 — #4
yup, i mentioned dropdowns, that works
stevenhu — 2011-02-03T11:47:51-05:00 — #5
OK, I'll keep it simple and go the drop-down route.