By SparkyUK on
Hi,
I'm using the following code - a modified version of something from the quick snippet pages. I'm not skilled (obviously) in PHP or SQL, so it is very likely that it was something in my modifications that has created the problem!
<?php
$listlength="4";
$content_type = 'page';
$taxo_id = 8;
$content_type2 = 'bookreview';
$result1 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n INNER JOIN term_node ON n.nid = term_node.nid WHERE n.type IN('$content_type', '$content_type2') AND n.status = 1 AND term_node.tid NOT LIKE $taxo_id ORDER BY n.created DESC"), $listlength);
while ($node = db_fetch_object($result1)) {
$output .= node_view(node_load(array('nid' => $node->nid)), 1);
}
print $output;
?>
What I was aiming to do was post the 4 most recent additions to the site which had a content type of either Page or Book Review. But, I also wanted to exclude pages that had the taxonomy term of "siteadmin", i.e. taxo_id 8.
The query seems to be working, but I am getting duplicate outputs for all bookreviews. Are bookreviews somehow also pages?
Is there a way to check the results and filter out duplicates from the output?
Comments
One way
Try adding DISTINCT to your SELECT query:
Have you looked at the views module? You can build these kinds of queries from within Drupal if you install the views module set.
Laura
_____ ____ ___ __ _ _
design, snap, blog
_____ ____ ___ __ _ _
Laura Scott :: design » blog » tweet
workaround
I've managed a work around using just tax terms which I think works. If someone knows about the content_type issue i'd love to know about it, but I seem sorted for now. Thanks.