How to update taxonomy field in a node? node_load($nid);
$node-&gt;mytaxonomyfield['und'][0]['tid']=$data;
node_save($nid)


my corresponding terms : online,offline,pre-online  and the corresponding tid : 1,2,3

my question : what the program will be that changing the field data by words instead of tid
You can't (at least not directly). Don't forget that multiple taxonomy terms may have the same name so they need to be identified by their tid or you'd get clashes.

You have a couple of options to load a taxonomy term by name, but for each you'll need to know the vid of the term's vocabulary.

The first option is to use the deprecated $conditions parameter of the taxonomy_term_load_multiple() function:

$terms = taxonomy_term_load_multiple(array(), array('name' =&gt; 'online', 'vid' =&gt; $vid));
$first_term = array_shift($terms);
$tid = $first_term-&gt;tid;


As you can see it's limited to loading just one term at a time.

The second (much better) way is to use an EntityFieldQuery:

$terms = array(
  'online',
  'offline',
  'pre-online'
);

$query = new EntityFieldQuery;
$query-&gt;entityCondition('entity_type', 'taxonomy_term')
  -&gt;propertyCondition('vid', $vid)
  -&gt;propertyCondition('name', $terms, 'IN');

$results = $query-&gt;execute();

if (isset($results['taxonomy_term'])) {
  // Get an array of tids
  $tids = array_keys($results['taxonomy_term']);
}


That way you can load multiple terms in one go, and take advantage of non-SQL field storage solutions if you need to.

If you're worried about speed you could also go directly into the taxonomy_term table to get this data; but I don't advise doing this unless you really know what you're doing.