$attr = explode(",", $node->field_xlnum[0]['value']);

the $node->field_xlnum[0]['value'] is like this: 20,4,56,987,68,96. it each node's nid. now i want to get all the title and output it in li list style. how do i do.

<?php
$attr = explode(",", $node->field_xlnum[0]['value']);
$result = db_query("SELECT nid,title FROM {node} WHERE nid in ($attr) AND type=%s order by created DESC",'test');
while(($items=db_fetch_object($result)){

$output = theme_item_list($items, array('class'=>'tabs primary'));

echo $output;

?>

but it can't work

Comments

nevets’s picture

I see two things.

%s is should be in single quotes ('%s')

This

while(($items=db_fetch_object($result)){

$output = theme_item_list($items, array('class'=>'tabs primary'));

should probably be something like

$items = array();
while(($node=db_fetch_object($result)){
  $items[] = $node->title;
}

$output = theme('item_list', $items, array('class'=>'tabs primary'));