Hi

all i am using this Query for fatching my data from my data base but it cant work will you please sugesst me where is the problame & what we are not doing please support me ASAP

$vid=1;$formname="Company";

$vocabulary = db_query("select term_data.name, term_data.tid from term_data where term_data.vid=2 and term_data.tid not in (select term_relation.tid1 from term_relation) ");
$options[] = t('List by ' . $formname); // Initialise the country array
//Populate array with url / name
while ($term = db_fetch_object($vocabulary)) {
$options['http://www.yoursite.com/taxonomy/term/'.$term->tid] = $term->name;
}
//Build dropdown select
//If we try to build OnChange directly it gets mangled, so put in array to confuse the forms api
$form['category'] = array(
  '#type' => 'select',
  '#name' => $formname,
  '#id' => $formname,
  '#title' => '',
  '#default_value' => '',
  '#options' => $options,
  '#description' => '',
  '#multiple' => $multiple = FALSE,
  '#required' => $required = FALSE,
  '#attributes' => array('onChange' => "top.location.href=document.getElementById('$formname').options[document.getElementById('$formname').selectedIndex].value"),
);
//Output the form
return drupal_get_form('Company_dropdown', $form);