how can i fill drop down list by database value ? to solve that i use fallowing code in my my_add_item.module file

$res = db_query("SELECT rest_id,rest_name FROM rest_details ORDER BY rest_name");
$options = array();

while ($o = db_fetch_array($res)) {
$options[$o->rest_id] = "t($o->rest_name)";
}

and then use this $options value in fallowing code

$form['user']['usertype'] = array(
'#type' => 'select',
'#title' => t('Select Usertype'),
'#description' => "Please select usertype.",
'#options' => $options,
),
);

this gives the error undefined "db_fetch_array()" while i use db_query() it is working fine
.... can anybody help me?

Comments

quicksketch’s picture

Category: Task » Support request
Issue summary: View changes
Status: Active » Closed (won't fix)

This question seems like a general Drupal coding question, not something specific to Webform module. But even so, we don't provide help with custom coding in the Webform issue queue.