How to use "taxonomy_get_childern" function //TID of current loaded node


&#60;?php
$nid = arg(1);
$tid1 = db_query("SELECT data.name,data.tid FROM field_data_field_books book
 INNER JOIN taxonomy_term_data data ON data.tid = book.field_books_tid
 WHERE book.entity_id = $nid ");

 foreach($tid1 as $t){
    print "Name ==> " . $t->name;
    print "Tid ===> " . $t->tid;
 }

 //function to load child term
 $child = taxonomy_get_children(32);
 foreach($child as $ch){
   print "Name===>" . $ch->name;

?&#62;


my question is that I want load tid dynamically instead of hardcore value 
I am using the above code in block please tell me how I am handle this situation?
In Drupal 7 you can use this code


  $nid = arg(1);//get the arugument
  if (arg(0) == 'node'  && is_numeric($nid)) {//check for node page
    $query = db_select('field_data_field_books', 'book');
    $query->fields('data', array('tid'));
    $query->innerJoin('taxonomy_term_data', 'data', 'data.tid = book.field_books_tid');
    $query->condition('book.entity_id', $nid, '=');
    $tid = $query->execute()->fetchField();//only one field
    $child = taxonomy_get_children($tid);//get your children
    foreach ($child as $ch) {
      print "Name===>" . $ch->name;
    }
  }