Hello everyone,
I am setting up a section of coding in which I need to add and subtract certain values to a mysql field. However ...the code only seems to add negative numbers (-13.0) as a postive number to the database and its really confusing me now! :(
What I have is a field in my database that contains a number that changes regulary.
For example say the number is -0.4.
I am trying to set this code up so that it multiplies the above number by 10 for example which would make it -4.0 and then inserts this new number into another database field.
However ....because the new number is a negative number I need the code to minus this value from the total in the database field!
Instead ...all it does is adds it to the database total as a postive number. Ive searched google and cannot seem to work this little problem out! :(
Here is my current code. because it didnt work by simply trying to add the new value to the current total in the database ...I have tried to first determine if the amount is above or below 0.0. If its below then the code should minus the new value from the amount and if its above 0.0 then it should add the new value to the amount but it doesnt work. Its still just adding the new value regardless of whether its negative or postive.
Any help would really be much appreciated!
Thank you
/////////start to calculate each total value!
/////////////////////////////////////////////////
$value = fetch ("SELECT * FROM material WHERE name='value'");
$units = $value[current] * $find_place[monthly_total];
///////does it go up or down
IF ($value[current] >=0.1)
{
$updown ==1;
}
else
{
$updown ==0;
}
IF ($updown ==1)
{
mysql_query("UPDATE places SET totaling=totaling+ $units WHERE area='1'");
}
IF ($updown ==0)
{
mysql_query("UPDATE places SET totaling=totaling- $units WHERE area='1'");
}
die(header(error("result.php?game=$game","Your update was successfull!")));