Jump to content


Photo

Insert from mysql with no decimal


  • Please log in to reply
2 replies to this topic

#1 neppers

neppers
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 01 March 2006 - 08:31 AM

I`m trying to make a payment method, but I need to forward the "order_total"-field from my mysql-database without decimals. Now I get f.ex an order_total like this "1679.00". I need it to be "167900". Anyone have an idea?

Sample from the code:
<input type="hidden" name="amount" value="<?php $db->p("order_total") ?>" />

#2 cheyner11

cheyner11
  • Members
  • PipPip
  • Member
  • 10 posts
  • LocationCalgary, Alberta, Canada

Posted 01 March 2006 - 10:04 AM

perhaps you could send the info into the database without the decimal. Then format the info if you ever needed to display it with a decimal.

The best way to remove the decimal is using REGEX.



#3 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 01 March 2006 - 10:27 AM

Multiply order total by 100
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users