I'm loosing values off the string?????
Posted: Sat Mar 26, 2005 2:27 pm
Hye
I've got a simple calculations which i'm doing. the first part of the query works fine, this is looking up the price of the item and then bringing it back. i then use my variable which has been filled by the form and extract the quantity. I then multiply the two togeother and insert the new value into the orders table.
the problem is that if the figure comes to say 2.20 i'm loosing the '0' and when the insert happens it comes as 2.2.
How can i overcome this problem????
The table which the look up is being performed on has a property of varchar for the price.
Can anyone help????
Code is as follows for the calculation
Any help appreciated
Shab

I've got a simple calculations which i'm doing. the first part of the query works fine, this is looking up the price of the item and then bringing it back. i then use my variable which has been filled by the form and extract the quantity. I then multiply the two togeother and insert the new value into the orders table.
the problem is that if the figure comes to say 2.20 i'm loosing the '0' and when the insert happens it comes as 2.2.
How can i overcome this problem????
The table which the look up is being performed on has a property of varchar for the price.
Can anyone help????
Code is as follows for the calculation
Code: Select all
$result = mysql_query ("SELECT Item_Description, Item_Price from item where item_id = '$item_id'",$connect)
or die ("There was an error in the query");
while ($row = mysql_fetch_assoc($result))
{
$item_description=$row['Item_Description'];
$price=$row['Item_Price'];
$total = $price * $quantity;
}
$query = ("INSERT INTO emp_order VALUES ('','$item_description','$quantity','$comments','$user_name','$total','Uncomplete')");Shab