Sainthax
07-28-2002, 10:20 PM
I have a website for a client that needs to be able to update it with interest rates, at the moment I have a php page that pulls the data and shows it on the main page on his site. I have a password protected page where he can update the info but whenever I type in something like 1.3% it saves it as 1 and only displays that, even when I try just 1.3 without the % sign it still only shows 1.
any ideas?
Gem Hexen
07-28-2002, 10:24 PM
it is probably an integer field that needs to be a floating point field (I don't actually know about mysql fields, but based on other programming...)
ScottD
07-28-2002, 10:56 PM
Use a DECIMAL(5,2) for a 5 digit percentage with 2 digits of precision (ie 100.00 or up to 999.99). Size it as needed.
Sainthax
07-28-2002, 11:18 PM
ok I changed that field to DECIMAL 5,2 and entered 6.25 for the value and it now shows 6.00
Sainthax
07-28-2002, 11:22 PM
If I'm just entering in a number like 6.25 then I "should" be able to use a text field correct?
EDIT: didn't work just displayed 6
ScottD
07-28-2002, 11:22 PM
How are you inserting the value? What is the statement?
> INSERT INTO rates VALUES (now(), 6.25)
Should produce a record with the current date and a decimal value of 6.25
Assuming:create table rates (
active_dt datetime,
rate decimal(5,2)
);
Sainthax
07-29-2002, 12:07 AM
ok now I feel stupid I looked in my php code and changed "int" to "decimal" on this line and now it works with the decimal 5,2 field in the database
GetSQLValueString($HTTP_POST_VARS['IRate'], "decimal"),