I need to insert a dynamic decimal in mysql. Meaning it could be 7.5 or 33.5 or 150.5. The final value is a percentage based on sales. I found this answer on stack: How to store decimal in MySQL? but it does not help me with my question.
Is there a simple way to store these examples?
3.5 or 47.5 or 246.5
If I use varchar the decimal does not show up. If I use the code form the answer above the decimal is off. Any suggestions?
UPDATE: Actually I think its my code. I can't seem to get the decimal to be in the right place. I am trying to get 30% of a random number. This code is not working right below
<?
$randomMade = 40;
$TotalMade = (30/$randomMade) * 100;
$TotalMade = round($TotalMade);
echo $TotalMade; // Comes out as 75 - But it should be 7.5
?>
UPDATE: Found percentage issue:
$TotalMade = (30*$randomMade) / 100; I had the math wrong. :(