How about you start by taking the time to more clearly describe your problem?
The general design for this sort of thing is called "data expiration" and "garbage collection." You put a DATETIME column into the database table that gives the expiration date of the row. After your initial connection to the database, you use a DELETE query something like this (pidgin code):
DELETE FROM mytable WHERE expiration_date < NOW()