0

I'm developing a Shopping Cart in PHP; after I have all my products, I have a $total.

If I have $ 14589.579 then I use number_format($total,2); to see $14,589.58.

But when I try to insert it into my database, I only see 14. The field on my database is type double.

This is my query:

"INSERT INTO cotizacion (
    idcotiza, idcli, idusuario, fechacotiza, pais, proyecto, notas, formapago, 
    tiempoentrega, flete, instalacion, venta, subtotal, descuento, total, 
    totalpesosmex, status, fecha2
) VALUES (
    NULL, '".$_SESSION['idcliente']."','".$_SESSION['idusuario']."', '".$fechatoday."',
   '".$pais."', '".$proyecto."', '".$notas."', '".$formapago."', '".$fechaentrega."',
   '".$flete."', '".$instalacion."', '".$venta."', NULL, NULL, '".$total."',
   '".$totalpesosmex."', 'Abierto', NULL
);"

Any idea about what I could do?

1 Answer 1

1

First, use DECIMAL to store money values.

Second, use REPLACE to remove the characters you dont want in a MySQL level.

Sign up to request clarification or add additional context in comments.

1 Comment

It's the only way??... Or... Ammmmm... Is there a way to rollback the format?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.