title: Adding a list of dates to a database
body: <p>I have two date selects on my website where the admin can select <code>"start date"</code> and <code>"end date"</code>. All of the dates from start to end will be then uploaded to the database. For example:</p>
  
  <pre><code>Start Date: 2015-01-01
  End Date: 2015-01-05
  
  Upload to database:
  2015-01-01
  2015-01-02
  2015-01-03
  2015-01-04
  2015-01-05
  </code></pre>
  
  <p>I have a code already in place to do this, although it is ONLY uploading ONE date to the database, the start date. Any ideas how I would get this working to upload all of the dates between the selected start and end dates? Here is my current code:</p>
  
  <pre><code>if(isset($_POST['add'])){
  
  $servername = "localhost";
  $username = "u779108225_admin";
  $password = "password";
  $dbname = "u779108225_main";
  
  // Create connection
  $conn = new mysqli($servername, $username, $password, $dbname);
  // Check connection
  if ($conn-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error);
  } 
  
  $date_from = $_POST['date_from']; 
  $date_from = strtotime($date_from); // Convert date to a UNIX timestamp
  
  // Specify the end date. This date can be any English textual format
  $date_to = $_POST['date_to'];
  $date_to = strtotime($date_to); // Convert date to a UNIX timestamp
  
  // Loop from the start date to end date and output all dates inbetween
  for ($i=$date_from; $i&lt;=$date_to; $i+=86400) {
      $date = date("Y-m-d", $i);
      $sql = "INSERT INTO calendar (date)
  VALUES
  ('$date')";
  
  }
  
  
  if ($conn-&gt;query($sql) === TRUE) {
      echo "New record created successfully";
  } else {
      echo "Error: " . $sql . "&lt;br&gt;" . $conn-&gt;error;
  }
  
  $conn-&gt;close();
  // Specify the start date. This date can be any English textual format
  
  
  
  }
  </code></pre>