I am trying to create a select list in drupal that is populated from a custom table in my db.
The table consists of a name and an id number. They are both unique.
I used this to collect the data from the db and to populate two arrays.
$query = "SELECT `id`, title` from {svm_mail_esp}";
$result = db_query($query);
$i=0;
while($row = db_fetch_array($result)) {
$listName[$i] = $row['title'];
$listID[$i] = $row['id'];
$i++;
}
Here is the $form array I used:
$form['esp_refferer'] = array(
'#type' => 'select',
'#title' => 'Service Provider',
'#required' => TRUE,
'#options' => $list,
'#cols' => 10,
'#default_value' => '- Choose -', //TODO: This needs to be fixed and the form cannot be processed while this is selected
'#multiple' => FALSE,
);
This is where my problem is coming in, I want to display the name, but when the form is submitted I need the $node->esp_refferer to be the id number and not the name.
How do I do this?
You need to create an array $list, Keys of that array will be ids and value of each will be respective title.