I want to create new variable in moodle and store it in the moodle database table mdl_config. So I can refer to this variable from another blocks or module. How can I do that? and how can I refer to this variable from other blocks.
Perhaps implementing a settings.php in your theme or block can be an idea:
$chk = new admin_setting_configtext( 'theme_xxx/chk', 'variable', 'help for variable', 'defaultvalue');
The value of this setting can be queried everywhere using $setting = get_config('theme_xxx', 'chk')