How to pass variable from module to other theme
For your needs, you'll need to create a custom module and implement hook_preprocess_html:

function hook_preprocess_html(&amp;$vars) {
  // This is where you do the db query
  $myvar = _get_my_var(); 

  // After this $myvar will be available in html.tpl.php
  // where you need to print it out
  $vars['myvar'] = $myvar;
}