I am trying to create a global price markup that will insert into the mysql table. I grab a variable from a simplexml element and multiply it by a number that is inserted by a form but the resulting answer is incorrect.
The variable calling from the xml file rounds up to a whole number and then multiples the $_post variable.
Sample..
$myprodprice = $myproduct->PRODUCTS_PRICE; // the xml value (sample is 2.33)
$mymarkup = $_post['mymarkup'];
echo $myprodprice;
echo $mymarkup;
$mymultiply = $myprodprice * $mymarkup;
echo $mymultiply;
Results will be
2.33
3.5
7
It ends up ignoring the xml variable decimal numbers when multiplying, but it will echo correctly otherwise.
Any help will be welcomed
Use
floatval()to convert the strings to float values before multiplying.