title: Javascript not adding variables from database up
body: <p>Hi guys so basically i am trying to add data in a nutrtion label which i built. So the label it self has everything from fat, carbs , protein etc. Now i have set up a database with:</p>
  
  <pre><code>ingName: ...
  fat: ...
  Carbs: ....
  etc etc 
  </code></pre>
  
  <p>So right now i am just trying to get it to work for fat. Once i do this i can easily do the others. I can search through the database easily.When the user presses Add button it will add the ingredient below the search box and then change the content of fat. However if the user adds anther record the fat content wont add up together. </p>
  
  <p>So for example i have Banana which has 4 fat and apple which has 1 fat. I add apple first and the fat content changes to 1 fat. When i add banana it should become 5 fat, however it will actually go to 4. So the records are not being added up correctly. </p>
  
  <p>Js:</p>
  
  <pre><code>        else{ 
              var searchedValue = $('#search_term').val(); 
              var temp2 = 0; 
              $.post( 'build.php', { 'search_term':searchedValue, 'current_fat':temp2 }, function(data) { 
              $('.result').html( data ); 
              }); 
              temp = $("#fat").text(); 
              temp = parseInt(temp); 
              current_fat += temp2; 
              current_fat += temp; 
              console.log(temp + " " + temp2 + " " + current_fat); 
              $("#fat").text(current_fat);
  </code></pre>
  
  <p>The part which is causing the problem is in the else loop, i cant seem to figure out how to fix it,</p>
  
  <p>If you need the php file i can get you that, but it seems to be in the else loop in the js file but i cant seem to figure out how to fix it. Been about a week i have been stuck on this mental problem :) </p>
  
  <p>Thanks anyway for the help x</p>