NoMansLand Posted March 29, 2011 Share Posted March 29, 2011 Hello, I am running this script: while($row = mysql_fetch_array($query)) { $compare_points_1 = $row['sideone_points']; $compare_villages_1 = $row['sideone_villages']; $compare_members_1 = $row['sideone_members']; $compare_points_2 = $row['sidetwo_points']; $compare_villages_2 = $row['sidetwo_villages']; $compare_members_2 = $row['sidetwo_members']; } $point_1 = $_POST['points_1']; $village_1 = $_POST['villages_1']; $member_1 = $_POST['members_1']; $point_2 = $_POST['points_2']; $village_2 = $_POST['villages_2']; $member_2 = $_POST['members_2']; $points_1_calc = $compare_points_1 - $point_1; $villages_1 = $compare_villages_1 - $village_1; $members_1 = $compare_members_1 - $member_1; $points_2 = $compare_points_2 - $point_2; $villages_2 = $compare_villages_2 - $village_2; $members_2 = $compare_members_2 - $member_2; When I try to output $points_1_calc it gives me: -100 It will Add & Times & Divide but not Subtract. Everything fills with Numbers only and I've tried this seperately and it works on a different script where I manually put in the numbers. All variables fill with numbers as I have a part above that doesnt go through if there is nothing to compare against. Any help would be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 29, 2011 Share Posted March 29, 2011 What does your query look like? Ken Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted March 29, 2011 Share Posted March 29, 2011 Will there be situations where the while loop will execute more than once? If so, the calculations should probably be inside the loop. Otherwise things like "$points_1_calc = $compare_points_1 - $point_1;" will only be calculated based on the values pulled from the last time through the loop. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.