Turning db rows into columns in Views

I have two custom database tables that I am trying to display in a specific way in Views. I was wondering if there is a way to do the following, or if someone has a recommendation of a better way to display this info.

The database tables are setup as follows:

Table 1:
gid - Primary ID for this table
desc - Description
url - A URL

Table 2:
mid - Primary ID for this table
gid - A foreign key that relates to a unique row in Table 1
attr - A simple attribute in an attribute/value pair
value - A simple value in an attribute/value pair

For each row in Table 1, there may be zero or more rows in Table 2 that link attribute/value pairs to the row in Table.

The client expects that the attributes from Table 2 that are attached to each row in Table 1 will typically be the same, so they would like the different attributes to show up as columns in Views table view. (i.e. there may be an attribute called "Location" that shows up for a bunch of rows in Table 1, so in the Views table view they want a column called "Location" and then the value would show up in that column for all rows that have a "Location" attribute. If they don't have the attribute, the cell would just remain empty.) The client's ultimate goal is to generate a table that can be easily copied over to Excel.

Form API + Database Help

I have created the following in a custom module:

function preimporter_form($form_state) {
global $user;

* Select from DB to get nid and name of Projects for a user

$result = db_query(
'SELECT n.nid, n.title ' .
'FROM {node} AS n ' .
'JOIN {field_data_field_users} AS fdfu ' .
'ON fdfu.entity_id = n.nid ' .
'WHERE fdfu.field_users_uid = :uid ',
array(':uid' => $user->uid)

//define rows
$options = array();
foreach ($result as $item) {
$options[$item->nid] = $item->title;

$form['project'] = array(
'#type' => 'select',
'#title' => t('Project'),
'#options' => $options,
'#required' => TRUE,
'#description' => t('Please select your Project for importing data'),

$form['submit'] = array(
'#value' => 'Submit',
'#type' => 'submit',

$form['user'] = array(
'#type' => 'hidden',
'#value' => $user->uid,

$form['session'] = array(
'#type' => 'hidden',
'#value' => $user->sid,

return $form;

* Implements hook_submit.
function preimporter_form_submit($form,&$form_state) {
global $user;
db_query("INSERT INTO {preimport} (project,user,session) VALUES (%d,%d,'%s')",

Shadowbox not showing images

I've got a fresh install of Shadowbox and I think I've done everything I'm supposed to do to get it working. However, it brings up the dark overlay and no image. Every time, including with the Test Shadowbox thing.

I did everything in this guy's videos, but it's broken right off the bat. Any ideas what I should do?

Drupal Commerce - How to programmatically get list products, ordered by price ASC/DESC, using EntityFieldQuery?

I'm having problem with EntityFieldQuery, the ->propertyOrderedBy()
Basically, I'm using Drupal Commerce, and my request is to get list of product (bundle = 'membership'), ordered by Product price increasing from lowest to highest
Here is my code to get the entities

DrOOPal Dreams

Why isn't Drupal designed for OOP? Please read by blog and comment:
DrOOPal Dreams

Thank you,

-=- PalaDolphin

Overriding the user_menu_title function

Hi all,

I'd appreciate some guidance in overriding a function. I have a site in which the client would like to see this:

Welcome, [username]
My profile | Log out

in the user menu for a logged-in user, rather than the default


Subscribe with RSS Subscribe to RSS - Drupal 7.x