I have a column named PRECIO
and another CANTIDAD
, column PRECIO
is in text format and the decimal separator has a comma, (this is the result of an excel export to mysql).
Achieve multiply PRECIO
x CANTIDAD
with this function:
tep_db_query("update " . TABLE_EXPORT . " set totales = cantidad * precio");
Now I need the result entered in totales
to contain 2 decimals.
What remains to be done, to obtain the result with 2 decimals considering that the value to multiply that contains the decimal is comma and in text format?
NOTE: I can not pass the text format to decimal because when it imports the field omits the decimals.
while:
$file = $_FILES['file']['tmp_name']; $handle = fopen($file, "r"); $id = 0; while(($filesop = fgetcsv($handle, 1000, ";")) !== false) { $cantidad = $filesop[10]; $precio = $filesop[11]; $sql = mysql_query("INSERT INTO TABLAX (id, cantidad, precio) VALUES ('$id++','$cantidad','$precio') }