title: Deleting and replacing a record from mysql after a certain date
body: <p>I am currently implementing a website where the admin user can post an offer which can be viewed by users. The offer has an expiry date which can be selected by the admin user. I am able to insert the offer details in the database. However I want to retrieve just one offer from the database which should only be displayed until the expiry date. After the expiry date, it should remove that offer from the database and  replace it with the next one in the database. </p>
  
  <p>I have a table called offers which has the following fields (<strong>offerid,offertitle,details,expirydate</strong>)</p>
  
  <p><strong>addoffer.php</strong> </p>
  
  <pre><code> $title =  $_POST['offertitle'];
   $details = $_POST['details'];
   $enddate = date('Y-m-d', strtotime($_POST['date']));
  
   $sqlquery = "INSERT  INTO `offers` (`offerid`, `offertitle`, `details`, `expirydate`) 
  VALUES ( NULL, '$title', '$details', '$date')";
    if($mysqli-&gt;query($sqlquery)){
        echo '&lt;h3&gt;Offer posted&lt;/h3&gt;';
    }else { 
        echo 'error';
    }
  </code></pre>
  
  <p><strong>view offer.php</strong></p>
  
  <pre><code>$mysqlquery = "SELECT * FROM offers";
  $results = $mysqli-&gt;query($mysqlquery);
  
  if ($results-&gt;num_rows &gt; 0) {
     while ($row = $results-&gt;fetch_assoc()){
        echo "". $row["offertitle"]. ""; 
     }
  }
  </code></pre>
  
  <p>Any way of doing this so the webpage only displays one offer until its expiry and then replace it with the next one in the database ??</p>