This is a flexible working version of the php script which extracts data from a mysql database.