<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16640" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>I would really appreciate someone helping me with
just a tiny bit of SQL code for some block code I got off d.o</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>here is the code:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><!-- 4 returned for each term, ordered by nid
descending, meaning new will always be at top --><BR><?php<BR>if (arg(0)
== 'node' && is_numeric(arg(1)) && is_null(arg(2))) {<BR>
$nid = (int)arg(1);<BR> $terms = taxonomy_node_get_terms($nid);<BR>
$output = "<span class='whole-list'>";<BR> foreach($terms as
$term){<BR> $sql = "SELECT n.title, n.nid FROM {node} n INNER
JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid = $term->tid AND n.nid !=
$nid ORDER BY RAND() LIMIT 3"; <BR> $result =
db_query(db_rewrite_sql($sql));<BR> if (db_num_rows($result))
{<BR> $output .="<h5
style='color:#900;font-weight:bold;margin-top:3px;'>$term->name</h5><ol
class='each-term'>";<BR> while ($anode =
db_fetch_object($result)) {<BR>
$output .= "<li>".l($anode->title,
"node/$anode->nid")."</li>";<BR> }
<BR> $output.="</ol>";<BR>
}<BR> }<BR> $output .= "</div>";<BR> return
$output;<BR>}<BR>?><BR></FONT></DIV>
<DIV><FONT face=Arial size=2>it shows other nodes with the same taxonomy terms
and I use it for a lot of Related Blog Posts, Related Forum Posts, type blocks.
But it doesn't check for publication status so I need to add "where status = 1"
at some part of the code. But where? Would I therefore also need to add n.status
in the SELECT part of the query? </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>any help much appreciated...these blocks are an
important part of my site but I'm getting nodes in moderation going into them
too.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Thanks</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Neil</DIV></FONT></BODY></HTML>