I have seen ways to use joomla command line interface (in 1.7 and later) to hook to strait php code to process things. There is a sample somewhere on Joomla.org i think about it.
If the site is running Joomla and K2 you might consider using a k2 override, strip it clean all except the extra fields loop, and instead of outputting them, just pass them to your php program or declare them global variables and then call your php file from there to use the data and return the html you want to return.
Otherwise, write code to access the table directly, and extract the extra field information directly from the field that contains all the extra fields in one string and use it.