Hello,
I would be happy to provide a function for you to return a country code. You wouldn't need a database table to store country codes... there are various external API's, and I would use one of them.
I would provide you with a PHP function which you could include in your script, along with a sample.
Thanks,
John