I'm using the following code to disply a list of nodes for recurring events. The site admin will just publish and unpublish as required.

My question is, should the H3 tag sill output if the query returns no result?

<?php
unset ($output);
$taxo_id = 12;
$list_no =5;
$sql = "SELECT node.title, node.nid FROM node INNER JOIN term_node ON node.nid = term_node.nid WHERE term_node.tid IN ($taxo_id) AND status = 1 ORDER BY node.created DESC LIMIT  $list_no";
$result = db_query($sql);
if ($result) {
  $output .= "<div id=\"events\">";
  $output .= "<h3>Upcoming Events</h3>";
  $output .= "<ul>";
  while ($anode = db_fetch_object($result)) {
    $output .= "<li>".l($anode->title, "node/$anode->nid")."</li>";
  }
  $output .= "</ul>";
  $output .= "</div>";
}
print $output;
?>

Comments

nevets’s picture

If you onlu want output where there are rows returned changed the if to

if ( db_num_rows($results) > 0 ) {
syawillim’s picture

Thank you nevets, it's just too easy when you know how.

www.slickfish.com.au
professional, affordable web site design, production and maintenance for small business