title: Return a new value and replace it everywhere
body: <p>I have a project at school with html and php and I have some problems.
  I have a database, and in my html I have a button to add friends to camping.
  I retrieve the value of how many friends he can add from the database, this is the code:</p>
  
  <pre><code>$campingNumber = $conn-&gt;query("SELECT * FROM reservation where email = '$email'")-&gt;fetch();
  $maxCampingPersons = (int) $campingNumber['persons_nb'] -1;
  </code></pre>
  
  <p>I am getting the max nr of persons that are allowed -1 because 1 of the persons is the leader.
   To show information about the camping I have this code:</p>
  
  <pre><code>&lt;td class="even"&gt; 
  &lt;?php echo is_null($user_account['camping']) == false ? $user_account['camping'] : 'No info'; ?&gt; , &amp;nbsp Camping place:&amp;nbsp
  &lt;?php echo is_null($campingNumber['spot_nb'])==false? $campingNumber['spot_nb'] : 'No info';?&gt;
  &lt;br/&gt; Number of friends you can add:&amp;nbsp 
  &lt;?php if($maxCampingPersons == -1) { echo ($maxCampingPersons) ==0 ? $maxCampingPersons : 'No info'; } 
  else { echo is_null($maxCampingPersons) == false ? $maxCampingPersons : 'No info';} ?&gt; 
  &lt;/td&gt;
  </code></pre>
  
  <p>And to add friends to camping I have this piece of code:</p>
  
  <pre><code>&lt;div&gt;
  &lt;?php if($maxCampingPersons&gt;0) { ?&gt;
        &lt;p&gt;&lt;input class="addcamping" type="button" value="Add friends to camping"   id="popup2-toggle" /&gt;&lt;/p&gt; &lt;?php }
   else {?&gt;
        &lt;p&gt;&lt;input class="addcamping" type="button" value="Add friends to camping" id="popup2-toggle" disabled /&gt;&lt;/p&gt; &lt;?php }?&gt;
  &lt;div class="popup2-overlay"&gt;
  &lt;div class="popup2"&gt;
  &lt;a href="#" class="popup2-close"&gt;X&lt;/a&gt;
  &lt;h2 style="color: black;"&gt;Hello &lt;?php echo $query['first_name']; ?&gt; &lt;/h2&gt;
  &lt;p style="color: black;"&gt;Add friends to your camping&lt;/p&gt;
  &lt;p style="color: black;"&gt;You can add &lt;?php echo is_null($maxCampingPersons)==false? $maxCampingPersons : '0';?&gt;  friend/friends to your camping&lt;/p&gt;
  
  &lt;?php if(isset($_SESSION['email'])){ ?&gt;
  
  &lt;form method="post" action="addCamping.php"&gt;
  &lt;div class="popup2-form-row"&gt;
  
  &lt;input type="text" id="popup2-form_login" value="" name="friendEmail" placeholder="friend@fontys.nl" /&gt;
  &lt;/div&gt;
  
  &lt;input class="addpeople" type="submit" value="Add friend" name="addCamping"/&gt;
  &lt;/form&gt;     
  
   &lt;?php } $maxCampingPersons= $maxCampingPersons - 1; ?&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;script type="text/javascript"&gt;
  p2 = $('.popup2-overlay')
  $('#popup2-toggle').click(function() {
  p2.css('display', 'block')
  })
  p2.click(function(event) {
  e = event || window.event
  if (e.target == this) {
  $(p2).css('display', 'none')
  }
  })
  $('.popup2-close').click(function() {
  p2.css('display', 'none')
  })
  &lt;/script&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>How can I do that after I add a friend <code>$maxCampingPersons</code> to be updated with -1 and to be updated everywhere? Because I've putted <code>$maxCampingPersons= $maxCampingPersons - 1</code> at the end of form but it's now working.</p>
  
  <p>Thank you,
  Alexandru</p>