I am trying to fill a CCK select box with a row from a database table, but the select box shows up empty. Here is the code I am using:

$res = db_query(db_rewrite_sql("SELECT `nid`, `field_neighborhood_name_value` FROM `content_type_neighborhoods` WHERE 1 ORDER BY `field_neighborhood_name_value` ASC"));
while ($item = db_fetch_object($result)) {
$items[$item->nid] = $item->field_neighborhood_name_value;
}
return $items;

This returns a keyed array per the instructions under the textarea, but the select list is empty. What am I doing wrong?

Comments

nevets’s picture

These two lines do not match up.

$res = db_query(db_rewrite_sql( ...

and

while ($item = db_fetch_object($result)) {

They both need to use $res (or both use $result).