Greetings,

I have a field value created by views php (variable: $row->php_2).

I am trying to add the total values for this field for all the rows returned in the view.

I am using the following in the "value code" text box of views php to do this:

$value = db_result(db_query("
SELECT SUM($row->php_2)
FROM content_type_time_sheet, node
WHERE content_type_time_sheet.nid=node.nid and node.status='1'
"));
Return $value;

The problem is it isn't adding the values in the column $row->php_2, it is taking the number of rows returned and multiplying that by each value in the $row->php_2 column.

What I would like is a sum of all the row values that are in the column $row->php_2. For example, if 5 rows are returned, I would like it to add the 5 values in $row->php_2.

If anyone can lend help on this, I would appreciate it.

Thanks in advance.

Comments

liam morland’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Drupal 6 is no longer supported. If this applies to a later version, please re-open and update the version.