How to delete a record when a specific date arrives?

0

Greetings again, I explain my case, I have in a table available courses that are going or are currently being taught each course with their specific data between them start date and end date, what I'm thinking of doing is that upon arrival the final date of the course, this is automatically deleted from my table available courses. The only thing that occurs to me is the conditional that could be like this:

if($row['fecha_final']==$fecha){
 $query = "DELETE FROM cursos_disponibles WHERE id = '$id'";
 $sql = $mysqli->query($query);
}

What I do not get is the way to get rid of me alone without having to give a button or something like that, that the course will be automatically deleted when that final date arrives. Thanks in advance who helps me.

    
asked by 26.08.2017 в 21:23
source

1 answer

-1

If you use sessions, you can perform a validation that every time you enter an automatic cleaning if it meets or not with the date.

if(isset($_SESSION['admin']))
{
   //validamos si es realmente es valida la fecha
     CONSULTA A LA BASE POR FECHA Y COMPARAMOS CON OTRO IF
    etc...etc etc.
   //aca generamos la consulta del DELETE

}
    
answered by 27.08.2017 / 07:02
source