U dont need mysql for this, u can use htaccess for this ...
But since u want to use mysql, u need to do something like this:
- when a visitor come on that page u make an insertion in your IP ban table and the date when the visitor enter
- your ip field could be uniq so if the insertion is not make then the visitor is still in the ban list
- set up a cron that delete all the records from that table that are older then 24 hours
This could do the trick ...