geo/modules/geo_data/geo_data.module, line 280
- Versions
- 6
geo_data_allowed_values($field)
Code
<?php
function geo_data_allowed_values($field) {
$options = array('' => t('Please select'));
$table = $field['geo_data_table'];
$select = array();
$select[] = $key = db_escape_string(check_plain($field['geo_data_key']));
if (!$table || !$key) return $options;
if (is_array($field['geo_data_value'])) {
foreach ($field['geo_data_value'] as $val) {
$select[] = db_escape_string(check_plain($val));
}
}
$orderby = count($select) > 1 ? $select[1] : $select[0];
$sql = "SELECT ". join(',', $select) ." FROM {". $table ."}";
$sql .= " ORDER BY $orderby";
$res = db_query(db_distinct_field($table, $key, $sql));
while ($row = db_fetch_array($res)) {
$key = array_shift($row);
$options[$key] = !empty($row) ? join(', ', $row) : $key;
}
return $options;
}
?> 