sorry kev, nobody on here will do your code for you - guaranteed.
what i generally say if you're stuck is to write some pseudo code
when a mail is sent:
load the total number of sent mails
add one to this
save it
then ask for pointers, and we'll say something such as "have a look at the php manual pages on [man]fopen[/man] (for reading from / writing to files) and [man]mysql[/man] for database access"
people on here are helpful, but they all give their help voluntarily, and as such will not be willing to help someone who isn't trying
adam