Well its quite simple really... you make a php page that queries the database for the stats. Then you take your base image... Create a new image with Gd image library.. place the base image onto it and then place the text on top .. all with php. Search google or
www.hotscripts.com.. tuts are all over the place.