title: Loop runs until the condition is met but insert statement is being used only once
body: <p>I am trying to create an Expense Management system where I will be able to schedule future expenses if the user selects frequency like daily, weekly, monthly etc.</p>
  <p>To achieve this, I have created a loop but in the code above, My loop runs, and $sde is echoed as desired but my insert statement runs only once. I want to run the insert statement for every updated date.</p>
  <pre><code>$sde=$arr['startdateexpense'];
  $ede=$arr['enddateexpense'];
  $modifiers=[
  &quot;Annually&quot;=&gt;&quot;+1 year&quot;,
  &quot;Daily&quot;=&gt;&quot;+1 day&quot;,
  &quot;Weekly&quot;=&gt;&quot;+1 week&quot;,
  &quot;Fort-nightly&quot;=&gt;&quot;+2 weeks&quot;,
  &quot;Monthly&quot;=&gt;&quot;+1 month&quot;,
  &quot;Quarterly&quot;=&gt;&quot;+4 months&quot;,
  &quot;Semi-Annually&quot;=&gt;&quot;+6 months&quot;,
                  ];
  while($sde &lt;= $ede){
  echo $sde , ' ';
  $modifier= $modifiers[$ExpenseFrequency];
  $sde = new DateTime($sde);
  $sde-&gt;modify($modifier);
  $sde= $sde-&gt;format('Y-m-d');                
  //Insert statement
  $sql = &quot;INSERT INTO expense (ExpenseDate, ExpenseCategoryName, ExpenseItem, ExpenseCost, Image, ExpenseDescription) VALUE ('&quot;.$sde.&quot;','&quot;.$ExpenseCategoryID.&quot;', '&quot;.$item.&quot;', 
               '&quot;.$costitem.&quot;', '&quot;.$tphoto.&quot;', '&quot;.$description.&quot;')&quot;;
      }
  </code></pre>
  <p>My $sde is updated every time but the only problem is with the insert statement.</p>
  <p>Can anyone please help me with this?</p>