westman Posted October 26, 2011 Share Posted October 26, 2011 hi all,am trying to take one number from anther.this is what i have... $number1 = 5;$number2 =2; $number1 = ($number1) - ($number2);$number1 = ($number1 - $number2); this is not working for me. My result is not 3 ie. 5-2=3 how do i do simple division in php? Link to comment Share on other sites More sharing options...
dsonesuk Posted October 26, 2011 Share Posted October 26, 2011 ??? Thats not division that subtraction, are you echoing out the result? as that should work $number1 = 5;$number2 =2; $number1 = ($number1) - ($number2); echo $number1; Edit: but you may want to use another variable for the end result, as you may which to use the original $number1 value again. $number1 = 5;$number2 =2; $result = ($number1) - ($number2); echo $result; Link to comment Share on other sites More sharing options...
westman Posted October 26, 2011 Author Share Posted October 26, 2011 its not working am sending the result to my database and seeing no changes Link to comment Share on other sites More sharing options...
nitesh Posted October 26, 2011 Share Posted October 26, 2011 <?php$number1 = 5;$number2 = 2;$result = $number1 − $number2;echo "$result";?> Link to comment Share on other sites More sharing options...
dsonesuk Posted October 26, 2011 Share Posted October 26, 2011 And wheres the code for sending it to the database, because the code supplied works! so it must be the transferring of this value to the database that is the problem. Link to comment Share on other sites More sharing options...
dsonesuk Posted October 26, 2011 Share Posted October 26, 2011 <?php$number1 = 5;$number2 = 2;$result = $number1 − $number2; echo "$result";?> Thats fine, IF you want text of '$result' to show for every result. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.