<!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>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>here is the code:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&lt;!-- 4 returned for each term, ordered by nid 
descending, meaning new will always be at top --&gt;<BR>&lt;?php<BR>if (arg(0) 
== 'node' &amp;&amp; is_numeric(arg(1)) &amp;&amp; is_null(arg(2))) {<BR>&nbsp; 
$nid = (int)arg(1);<BR>&nbsp; $terms = taxonomy_node_get_terms($nid);<BR>&nbsp; 
$output = "&lt;span class='whole-list'&gt;";<BR>&nbsp; foreach($terms as 
$term){<BR>&nbsp;&nbsp;&nbsp; $sql = "SELECT n.title, n.nid FROM {node} n INNER 
JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid = $term-&gt;tid AND n.nid != 
$nid ORDER BY RAND() LIMIT 3";&nbsp; <BR>&nbsp;&nbsp;&nbsp; $result = 
db_query(db_rewrite_sql($sql));<BR>&nbsp;&nbsp;&nbsp; if (db_num_rows($result)) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $output .="&lt;h5 
style='color:#900;font-weight:bold;margin-top:3px;'&gt;$term-&gt;name&lt;/h5&gt;&lt;ol 
class='each-term'&gt;";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while ($anode = 
db_fetch_object($result)) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
$output .= "&lt;li&gt;".l($anode-&gt;title, 
"node/$anode-&gt;nid")."&lt;/li&gt;";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp; 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $output.="&lt;/ol&gt;";<BR>&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp; }<BR>&nbsp; $output .= "&lt;/div&gt;";<BR>&nbsp; return 
$output;<BR>}<BR>?&gt;<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>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Thanks</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Neil</DIV></FONT></BODY></HTML>