Loading cck fields from nodes of a content type I have created 4 nodes by a content type called insert_item using CCK; now I am trying to load all CCK fields into a template of a new node where I would use the CCK field value of the insert_item content type.

What I have written is the following code:

$nodes = array();
$result = db_query("SELECT nid FROM {node} WHERE type = 'insert_item'");
while ($row = db_fetch_object($result)) {
  $nodes[] = node_load($row-&gt;nid);
  print $nodes;
}


What I got is the following:


  ArrayArrayArrayArray


I really don't know what to do.
Try changing print $nodes to print_r($nodes) and also move it to the outside of your while loop.

Your code should look like this:

$nodes = array();
$result = db_query("SELECT nid FROM {node} WHERE type = 'insert_item'");
while ($row = db_fetch_object($result)) {
  $nodes[] = node_load($row-&gt;nid);
}
print_r($nodes);
//If you use Devel, uncomment this next line and comment out print_r above
//dpm($nodes);


This will give you an easy to read value.

Another option is to use the Devel module, and instead of using print_r you can use dpm() which uses Krumo to pretty print the contents of your array.  There are some basic instructions for that dpm() here and here.

Information on print_r here.


  If given an array, values will be presented in a format that shows
  keys and elements. Similar notation is used for objects.