I am new to Drupal and developing my first Drupal site. So, this is probably a very basic question.
I used the Drupal 7 user interface and created a custom node type called 'groups'. In addition to the default fields (name and description), I added several custom fields. One new text field is called "manager". When I created the field via the user interface, the field name was automatically prepended with "field_", so the new field appears to have the name "field_manager". This is fine so far. Next, I created an instance for the new node type. So, now the node has some content.
Now, I am attempting to access this instance in a module. For reference, I used a sample from "Pro Drupal 7 Development" - see below,
$sql = 'SELECT nid FROM {node} n WHERE n.type = :type';
$result = db_query($sql, array(':type' => 'groups'));
$nids = array();
foreach ($result as $row) {
$nids[] = $row->nid;
echo $row->nid;
}
This worked great and displayed the node ID for my single instance.
Next, I added the following code to retrieve the "title" for the node instance,
$sql = 'SELECT title FROM {node} n WHERE n.type = :type';
$result = db_query($sql, array(':type' => 'groups'));
$titles = array();
foreach ($result as $row) {
$titles[] = $row->title;
echo $row->title;
}