Dynamic select list in the form API (dependent dropdown list)?
Basically, in your form declaration, you have to add

In your form['state'] :

'#ajax' =&gt; array(
  'callback' =&gt; '_ajaxfunction',
  'wrapper' =&gt; 'divaroundseconddropdown'
);


Then in your form['town'] :

'#prefix' =&gt; '&lt;div id="divaroundseconddropdown"&gt;',
'#suffix' =&gt; '&lt;/div&gt;',


Now in your _ajaxfunction :

function _ajaxfunction($form, $form_state) {
  return $form['city'];
}


Now, back to your form['town'], you simply have to build your $options with the $form_state['values']['state'] variable, which will contain what has been filled in the first dropdown.

Everything is documented here.

[EDIT]

First replace $state_record in your $query_city by $form_state['values']['state']; *You can check if the value is formatted the right by dpm($form_state); in your _ajaxfunction.

Then :

$form['state']= array(
  '#type' =&gt; 'select',
  '#title' =&gt; t('State'),
  '#options' =&gt;$options_state,
  '#required' =&gt; TRUE,
  '#ajax' =&gt; array(
    'callback' =&gt; '_ajaxfunction',
    'wrapper' =&gt; 'divaroundseconddropdown'
  ),
);


$form['city']= array(
  '#type' =&gt; 'select',
  '#title' =&gt; t('District'),
  '#options' =&gt; $options_city,
  '#prefix' =&gt; '&lt;div id="divaroundseconddropdown"&gt;',
  '#suffix' =&gt; '&lt;/div&gt;',
  '#required' =&gt; TRUE,
  '#states'=&gt;array(
    'visible'=&gt;array(
      ':input[name="state"]' =&gt; array(
        'value'=&gt;$options_state))));


Close your function, open a new one :

function _ajaxfunction($form, $form_state) { return $form['city']; }