I'm late to this thread, and maybe you have it sorted already, but.... You looking for PHP/MySQL help particularly for blocking ip ranges, right? Cuz'. if you have root access (and aren't on a cheap virtual host or something), why not do thissimply through IP tables.
Something like this to block a whole subnet: iptables -A INPUT -s 192.168.100.0/24 -j DROP
I just stumbled onto this site which creates country specific IP ranges for blocking. It seems really spot on, even generates P tables rules.
If you can't use iptables, you can always do something similar using .htaccess. This way you don't need to add much of anything to the box.