How to show list of nodes that belong to a particular vocabulary in Drupal 5

If you have a vocabulary with several terms in your drupal 5 web site, you may want to show list of recent items in that vocabulary in a block or a page. I tried to do this with views module, but I could only show nodes
belong to one specific term, and that was not what I had in mind.
For some reason I needed to create a simple module for myself and make a new path to the page I wanted to create and then write the code to show list of nodes in a particular vocabulary. But if you don’t need more functionality and the only thing you want is the show a block or page of nodes, you can define a node/block with input type as “php” and then add this code inside it.
The relationship between nodes and terms are saved in {term_node} table with nid (node) and tid (term) fields. Then from {term_data} table we can find out the relation between tid (term) and vid (vocabulary). We could do a simple join between node table and these two tables and get a list of nodes which belong to a vocabulary. But there is a bit of a problem there. Each node may be related to more than one vocabulary and unfortunately DISTINCT will not work for this kind of join. So first we have to get all nodes from this join query and then traverse the result and make it unique based on nid.


nid);
      $created = format_date($node->created); /*This is a simple customization of output
 html, you can change it the way you like.*/
      $output .= "
"; $output .= "

{$node->title}

"; $output .= ""; $output .= "
{$node->teaser}...$link
"; $output .= "

"; } } else { $output = "There is no post in this section yet"; } print $output; ?>