title: Update status when overdue
body: <p>I'm doing a small rental system where my SQL database will record the details of the product rented by the customer and an overdue date. if the date surpass the overdue date, the 'status' will be automatically set from &quot;Currently Renting&quot; to &quot;Overdue&quot;. As of right now, this is what I could think of but of course, the logic is wrong from my codes. Please see the attached image as well for a clearer observation.</p>
  <p>PHP</p>
  <pre><code>&lt;?php
  $servername = &quot;localhost&quot;;
  $username = &quot;root&quot;;
  $password = &quot;&quot;;
  $dbname = &quot;assignment3&quot;;
  
  
  
  // Create connection
  $conn = new mysqli($servername, $username, $password, $dbname);
  // Check connection
  if ($conn-&gt;connect_error) 
  { 
  die(&quot;Connection failed: &quot; . $conn-&gt;connect_error);
  }
  
  $retrieve = mysqli_query($conn,&quot;SELECT * FROM rentproducts WHERE status = 'Currently Renting'&quot;);
  $row = mysqli_fetch_array($retrieve);
  $today = new DateTime(date(&quot;d-m-Y&quot;));
  $overduedate = new DateTime($row['overduedate']);
  $overduedays = $overduedate-&gt;diff($today)-&gt;format(&quot;%a&quot;);
  echo $overduedays;
  
  if ($overduedays &gt;= 1) 
  {
      $sql = &quot;UPDATE rentproducts SET status = 'Overdue' WHERE status = 'Currently Renting'&quot;;
      mysqli_query($conn, $sql);
  }
  ?&gt;
  </code></pre>
  <p><a href="https://i.stack.imgur.com/9u0vN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9u0vN.jpg" alt="SQL Database" /></a></p>