Community Documentation

getting data from a nodereferrer

Last updated October 25, 2008. Created by Matt B on October 25, 2008.
Log in to edit this page.

I have the nodereferrer module installed and want to use data in a field in the node that refers to this node. This is the code I used

$r= db_result(db_query("SELECT `nid`FROM `content_field_recordingparts`WHERE `field_recordingparts_nid` = %d",$node->nid));
$node_field[0]['value'] = db_result(db_query("SELECT field_recordingid_value FROM content_type_recording_data WHERE nid=%d",$r)) . "." . $node->field_recordingnum[0]['value'];

recordingdata has a node reference set up on recordingparts, and the reference between the recordingdata nodes (nid) and recordingparts nodes (field_recordingparts_nid) is stored in a table called content_field_recordingparts. The data I want is in the recordingid field on the recordingdata node, and I want to append a "." and the value of another field in the current node.

hope this makes sense and is helpfull to others. I'd be interested if there was a simpler way of doing this!

About this page

Drupal version
Drupal 6.x

Site Building Guide

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.