Why isn't there any output? $results = db_query("select nid from {taxonomy_index} where tid = :tid", array(':tid' =&gt; arg(2)));
foreach ($results as $result) {
  $node = node_load($result-&gt;nid);
  echo $node-&gt;title;
}


I put the code in page--taxonomy.tpl.php, but there is no result. Why?

The output of print_r($results) is the following one.

DatabaseStatementBase Object
(
    [dbh] =&gt; DatabaseConnection_mysql Object
        (
            [shutdownRegistered:protected] =&gt; 
            [target:protected] =&gt; default
            [key:protected] =&gt; default
            [logger:protected] =&gt; 
            [transactionLayers:protected] =&gt; Array
                (
                )

            [driverClasses:protected] =&gt; Array
                (
                    [SelectQuery] =&gt; SelectQuery
                )

            [statementClass:protected] =&gt; DatabaseStatementBase
            [transactionSupport:protected] =&gt; 1
            [transactionalDDLSupport:protected] =&gt; 
            [temporaryNameIndex:protected] =&gt; 0
            [connectionOptions:protected] =&gt; Array
                (
                    [database] =&gt; 
                    [username] =&gt; 
                    [password] =&gt; 
                    [host] =&gt; 
                    [port] =&gt; 
                    [driver] =&gt; 
                    [prefix] =&gt; Array
                        (
                            [default] =&gt; 
                        )

                )

            [schema:protected] =&gt; 
            [prefixes:protected] =&gt; Array
                (
                    [default] =&gt; 
                )

            [prefixSearch:protected] =&gt; Array
                (
                    [0] =&gt; {
                    [1] =&gt; }
                )

            [prefixReplace:protected] =&gt; Array
                (
                    [0] =&gt; 
                    [1] =&gt; 
                )

        )

    [queryString] =&gt; select nid from taxonomy_index where tid = :tid
Please confirm you got any value from arg(2) which is equivalent to term id(tid) .

Try this code

$result = db_select('taxonomy_index', 't')
  -&gt;fields('t')
  -&gt;condition('tid', arg(2), '=')
  -&gt;execute()
  -&gt;fetchAssoc();

$node = node_load($result-&gt;nid);

print_r($node);