By gettysburger on
I have a CCK field called "field_course_number". I wish to use it in a query that resides in a custom block on the same page as a node that contains the "field_course_number".
db_set_active('hcc');
$result = db_query("SELECT * FROM 09SP_COURSES WHERE courseNumber="field_course_number" ");
db_set_active('default');
while($value = db_fetch_array($result)){
print $value["title"] .' , ';
print '<br />';
}
I am sure I have the syntax wrong, but can't figure it out. Any thoughts would be appreciated. Thanks.
Comments
node_load();
if you are on the node page you should be able to do
There is input in this
There is input in this query, so this query should be:
http://xkcd.com/327/
Fourth Wall Media
Toronto, Canada
Thanks...
...now I see that you meant me to add this to the first reply.
This works!
Thanks a million. I put your two examples together and it works for me.
I also need to compare 'courseLetters' to 'field_course_letters' in the same WHERE statement.
This breaks. Now that you kind folks have pointed me to db_query I am checking out the Pro Drupal Development book to see if I can figure out the syntax for multiple WHERE statements that include placeholders. Thanks again.
Sweet Success
I figured it out. I was missing the single quotes around the string placeholder ('%s'). Here is the final code:
Great, glad this worked for
Great, glad this worked for you! :)
Fourth Wall Media
Toronto, Canada