hello everyone
am trying to insert a division calculation into a mysql column but am unable to get mysql render the result together with the remainder.
I understand i can get the remainder with the Mod or % operator,but that only returns the remainder alone
i want 18/180 to return 0.1 or 0.10
how can i do this
currently it returns 0 ( no odd numbers ,just even ones.)
thank you for your help
[php]
$period=180;//180 days
$cost=18;//$18.00
$query = "INSERT INTO mytable (id,cost,period ,cost_per_day) VALUES
('$id',$cost,$p eriod,(cost/period)";
mysql_query($qu ery);
[/php]
cost_per_day field is decimal(integer makes no difference
am trying to insert a division calculation into a mysql column but am unable to get mysql render the result together with the remainder.
I understand i can get the remainder with the Mod or % operator,but that only returns the remainder alone
i want 18/180 to return 0.1 or 0.10
how can i do this
currently it returns 0 ( no odd numbers ,just even ones.)
thank you for your help
[php]
$period=180;//180 days
$cost=18;//$18.00
$query = "INSERT INTO mytable (id,cost,period ,cost_per_day) VALUES
('$id',$cost,$p eriod,(cost/period)";
mysql_query($qu ery);
[/php]
cost_per_day field is decimal(integer makes no difference
Comment