Main menu

set CCK default value from query (Multi-Value)

26 Apr
Published by Mark W. Breneman

Just in case you may need to populate a CCK field from a db query OR more to the point, next time I have to:

global $user;
$qdata= 'db_query(SELECT field_school_studyareas_value
FROM
content_field_school_studyareas
where nid in (select nid from node WHERE node.type in ("exhibitor_profile") and uid ='.$user->uid.')) ' ;

while ($row=db_fetch_array($qdata))
{
$var[]=array('value' =>$row['field_school_studyareas_value']);
}
return $var;

Yes a join would have been far better. I'll fix that soon.

Category 

Bookmark, Drupal

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.