title: While loop doesn't stop (PHP)
body: <p>I want to make statistics by day, month, years, for my website</p>
  
  <p>so first I checked if the database is empty if that correct I insert today date with 1 in the count </p>
  
  <p>but for example if I have the last day in database is 2016-03-28 I need to add to 2016-03-31 and 2016-04-01 ..... 2016-04-30 ... etc to today's date.</p>
  
  <p>I make it but I have a problem the while loop doesn't stop sow it's work but when he went to today's date it's doesn't stop </p>
  
  <pre><code>&lt;?php
  while($rows['st_date'] != $date1 ){
      if($rows['st_date'] != $date1) {
          $akhir = $datedate1 - $date_day;
          $akhir_month = $date3 - $date_month;
          if($akhir_month != 1 &amp;&amp; $akhir &gt; 0) {
              $n = $akhir;
              for($j=1; $j&lt;=$n; $j++){
                  $date5 = ++$date_day;
                  $date6 = $date_month;
                  $date7 = $date_years;
                  $final_date = $date7.'-'.$date6.'-'.$date5;
                  $sql3 = "INSERT INTO statistics (st_date, count) values ('$final_date', '0')";
                  mysqli_query($conn,$sql3);
              }
          }
          else if ($akhir_month &gt; 1){
              $datemonth1 = ++$date_month;
              $date_day = 1;
              $datefinal = $date_years.'-'.$datemonth1.'-'.$date_day;
  
              $datedate1 =  date("t",strtotime($datefinal));
              $akhir = $datedate1 - 0;
              $n = $akhir;
              $datetest = $date_month;
              for($j=1; $j&lt;=$n; $j++){
                  $date5 = $j;
                  $date6 = $datetest;
                  $date7 = $date_years;
                  $final_date = $date7.'-'.$date6.'-'.$date5;
                  $sql3 = "INSERT INTO statistics (st_date, count) values ('$final_date', '0')";
                  mysqli_query($conn,$sql3);
              }
          }
          else if ($akhir_month == 1) {
              $n = $resm;
              $i = 1;
              for($j=1; $j&lt;=$n; $j++){
                  $date5 = ++$i;
                  $date6 = $date3;
                  $date7 = $date_years;
                  $final_date = $date7.'-'.$date6.'-'.$date5;
                  $sql3 = "INSERT INTO statistics (st_date, count) values ('$final_date', '0')";
                  mysqli_query($conn,$sql3);
              }
          }
  
          $sql3 = "UPDATE statistics SET count = '1' where st_date = '$date1'";
          mysqli_query($conn,$sql3);
      }
  
      else if($rows['st_date'] == $date1) {
          break;
      }
  }
  </code></pre>
  
  <p>I want to exit the while when the last date in the database == today date</p>