Run DB query and fetch fields in block--block--ID.tpl.php
It sounds like you want to enable Tokens on your site and use a token to show the subdomain name in your block, after adjusting the Input Format for the block.

There really isn't coding involved, unless the subdomain module does not provide token support (then implement hook_token_info).