I'm sure someone who has done this before will provide better help, but I'm finding out some info...
I downloaded a list of zips, but **** if I can remember where I got it. I'll see if I can find the link again (got it through google). The file I downloaded was zip.txt.gz. It contains a comma-delimited list of zips, states, cities and longitude/latitude info.
You'd probably want to import that into your database, I'm more familiar with SQL server and postgresql than mysql, so I can't help out too much with specifics there.
As far as scripts to do the calculations, I haven't found any free ones yet. There's this one for $74 that does exactly what we want: http://keskydee.com/geozip.php
I'm probably going to try using code from this page (it's Perl but the algorithm should be the same in any language) unless I find a ready-to-go script:
http://jan.ucc.nau.edu/~cvm/latlongdist.html
My biggest concern is keeping the zips up-to-date. We are building the site for someone and turning it over to them, so unless we tack on a maintenance clause, the db will eventually be obsolete to some degree. Hate to tell the client that they need to hire someone every year to grab another db, but if that's what they have to do so be it.
Anyway, I'll try to put together something from that script and if it works you're welcome to it. I'm pretty slow with php though, I normally use Cold Fusion!
Rick