How do I get the taxonomy term ID from its name?
taxonomy_get_term_by_name() will do the trick:

$terms = taxonomy_get_term_by_name($row-&gt;field_term_name);
if (!empty($terms)) {
  $first_term = array_shift($terms);
  print $first_term-&gt;tid;
}