Google Answers Logo
View Question
 
Q: Drupal CMS, MySQL database, displaying items on a term ( No Answer,   0 Comments )
Question  
Subject: Drupal CMS, MySQL database, displaying items on a term
Category: Computers > Programming
Asked by: griffin05-ga
List Price: $10.00
Posted: 15 Oct 2006 22:05 PDT
Expires: 22 Oct 2006 08:18 PDT
Question ID: 773931
Drupal CMS, MySQL database, displaying items on a term

i wish to display content by its term (taxonomy used), i need to
display both the teasers and list,  i was able to get and display
content by type and list the recent forum and blog posts, however, i
couldnot get get and diplay conteny by term the way i wanted.

i have this code.. that displays ALL items from the term id given... 

<?php
  $term_id = 1;
  $query1 = db_query("SELECT nid FROM {term_node} WHERE tid = 1");
  while ($node = db_fetch_object($query1)) {
    $output1 .= node_view(node_load(array('nid' => $node->nid)), 1);
  }
print $output1;
?>

as I said this displays all the content, even unpublished and the ones
on moderations...

the solution is easy...

every term has a tid, and every content (node) has a nid, the
"term_node" table has the relationship info on tid and nid, so... i
need to use tid to find out, what 'nid' have them, i have done this in
the code above...

the second step is to find all the content (nodes) that have the nid
from query1 from the "node" table, we just need to use the result from
that first query on the second one... i tired doing that here...

<?php
  $term_id = 1;
  $query1 = db_query("SELECT nid FROM {term_node} WHERE tid = 1");
  $result1 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM
{node} n WHERE n.nid = '$query1' AND n.promote = 1 AND n.status = 1
ORDER BY n.created DESC"));
  while ($node = db_fetch_object($result1)) {
    $output1 .= node_view(node_load(array('nid' => $node->nid)), 1);
  }
print $output1;
?>

but.. it does not work.. and i dont know how to use query result from
one on another query two...

i want the query...
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy