title: PHP complex while-loop logic
body: <p>I'm having a problem writing a suitable while loop logic in php, here is my code:</p>
  
  <pre><code>$applied_to = "Battery";            # rule applies to this product
  $items      = $_GET['items'];       # how many items we have of this product
  $forquan    = 3;                     # rule applies to this quantity of product
  $autoadd    = "Power Inverter";  # when rule is met add this product.
  
  if ($applied_to == "Battery"){
      print "We Have $items $applied_to&lt;br&gt;";
      print "The rule says we need 1 $autoadd for each 1-$forquan $applied_to&lt;br&gt;&lt;hr /&gt;";
  
      $counter = $items;
      while($counter &gt; 0){
          if ($forquan / $items &gt; 1){
              print "we need 1 $autoadd&lt;br&gt;";
          }
          $counter--;
      }
  }
  </code></pre>
  
  <p>Now what i want is to add one additional product <code>$autoadd</code> if we have 1-3 Batteries, and 2 <code>$autoadd</code> if we have 3-6 and so on.</p>
  
  <p>I tried so many different combinations of while loops if statements etc, but i cant seem to get the perfect loop.</p>