good day everyone.
I have a problem. I have a mySQL database namely "prices" and a table name of "pricesTbl".
the pricesTBL table consist of 3 fields namely, id, expense, revenue.
id = INT
expense = DECIMAL(10,2)
revenue = DECIMAL(10,2)
I know how to display it in my form's textfield. But when i tried to set new price and edit those fields, it doesn't store the exact amount that i have entered in the form. For example, i entered 3000.00 in expense field, and 5000.00 in the revenue field, the thing that it will store in my database is 3.00 and 5.00...
Does anyone know how to solve this up?
store as DECIMAL datatype in MySQL db
Moderator: General Moderators
-
pawarnilesh4u
- Forum Newbie
- Posts: 6
- Joined: Thu Aug 21, 2008 10:16 am
- Location: Mumbai - India
Re: store as DECIMAL datatype in MySQL db
I dont know whether you are doing this or not but While writing insert query like
insert into tablename (id, expence, revenue) values('1','100.20','12000.00');
if you are taking values from somewhere it must be like this
$sql="insert into tablename (id, expence, revenue) values('1','".$value."','".$value2."');";
insert into tablename (id, expence, revenue) values('1','100.20','12000.00');
if you are taking values from somewhere it must be like this
$sql="insert into tablename (id, expence, revenue) values('1','".$value."','".$value2."');";
Re: store as DECIMAL datatype in MySQL db
I'm using this code to display it in my page
What should i do in order for me to store data in my database just like what i've entered in my form
Code: Select all
$row=mysql_fetch_array($result);
$a=$row['deluxeSingle'];
$b=$row['deluxeDouble'];
$c=$row['superSingle'];
$d=$row['superDouble'];
$e=$row['junior'];
$f=$row['executive'];
$g=$row['senior'];
$h=$row['imperial'];
$i=$row['royal'];
$j=$row['extraPerson'];
$da = "P ".number_format($a, 2, '.', ',');
$db = "P ".number_format($b, 2, '.', ',');
$dc = "P ".number_format($c, 2, '.', ',');
$dd = "P ".number_format($d, 2, '.', ',');
$de = "P ".number_format($e, 2, '.', ',');
$df = "P ".number_format($f, 2, '.', ',');
$dg = "P ".number_format($g, 2, '.', ',');
$dh = "P ".number_format($h, 2, '.', ',');
$di = "P ".number_format($i, 2, '.', ',');
$dj = "P ".number_format($j, 2, '.', ',');Re: store as DECIMAL datatype in MySQL db
Show us your insert query.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Re: store as DECIMAL datatype in MySQL db
here is the insert query code
thank you for your kindness
Code: Select all
// Define $myusername and $mypassword
$a=$_POST['a'];
$b=$_POST['b'];
$c=$_POST['c'];
$d=$_POST['d'];
$e=$_POST['e'];
$f=$_POST['f'];
$g=$_POST['g'];
$h=$_POST['h'];
$i=$_POST['i'];
$j=$_POST['j'];
// update data in mysql database
$sql="UPDATE $tbl_name SET deluxeSingle = '$a', deluxeDouble = '$b', superSingle='$c', superDouble='$d', junior ='$e', executive = '$f', senior = '$g', imperial = '$h', royal = '$i', extraPerson = '$j'";
$result=mysql_query($sql);