I am working on mobile app which has a mysql backend
. Mysql is already desined database and currently running for the PC site too. So, I am developing separate front-end on mobile, but using the same database and writing my own php code to update the same database. My problem is that database has a column(price) whose type is float
(giving type as only float with no extra information like (5,4) when I used desc.).
Problem is --> When I insert data as it is, like if user enters 1234
, I am inserting into database as 1234 and it is stored in the same way. But when the same information is shown on the PC site, it displays 0.01 as 1234
. So, I did some search on the data that is inserted from the PC site. They are inserted into database column like 1234000000
, if user inserts 1234. While on the price info on website it shows correct price like 1234.
So, do I need to append six 0's to my number to the end of it before inserting in my mobile php code or is there any type of formatting technique? Any help is greatly appreciated. Thanks in advance.
EDIT : Code snippet
$price = mysql_real_escape_string($_POST[$enteredprice]);
mysql_query("INSERT INTO item(s_secret, i_price)
VALUES('$secretcode','$price')",$db);
Where $price contains the value of price that user entered. As my above explanation, if user enters 1234, $price contains 1234.