OK, so I solved it myself.
Open and edit the webform.submissions.inc file in the includes folder of the module
In the Return all the submissions for a particular node. section find the code with the comment "// Join to the users table to include user name in results."
// Join to the users table to include user name in results.
$pager_query->leftJoin('users', 'u', 'u.uid = ws.uid');
$pager_query->fields('u', array('name'));
if (isset($filters['u.uid']) && $filters['u.uid'] === 0) {
if (!empty($_SESSION['webform_submission'])) {
$anonymous_sids = array_keys($_SESSION['webform_submission']);
$pager_query->condition('sid', $anonymous_sids, 'IN');
}
else {
$pager_query->condition('sid', 0);
}
}
To add my country section I had to find the table in phpMyAdmin that contained my taxonomy data. In this case it was "field_data_field_counrty" (I've spelled country wrong i know but I couldn't change it after).
From that I figured out that the entity ID was the the user ID in the Users table. This is because I had used the country taxonomy on the registration form.
The syntax for the inner join query is 'Table, Table Alias, Condition, Arguments'.
From that my innerjoin became,
$pager_query->innerJoin('field_data_field_counrty ', 'fld_Country', 'fld_Country.entity_id = ws.uid' );
The field syntax is 'Table Alias, Field Name', so my field selection became,
$pager_query->fields('fld_Country', array('field_counrty_tid'));
This gave me the country ID number that had been assigned to the taxonomy term. I then had to cross reference that field with the taxonomy data table to retrieve the name of the country the ID referred to. That was done with another innerjoin.
$pager_query->innerJoin('taxonomy_term_data ', 'taxonomy_Country', 'taxonomy_Country.tid = fld_Country.field_counrty_tid' );
This time the field I needed to retrieve was called name. However, 'name' had already been used further up in the original code for the user name. So to add an alias to the field I had to use addField instead of fields. The syntax for addField is 'Table Alias, Field, Alias'. My code became,
$pager_query->addField('taxonomy_Country', 'name', 'tax_name');
The code as a whole is:
// Join to the field country table to include Country ID in results.
$pager_query->innerJoin('field_data_field_counrty ', 'fld_Country', 'fld_Country.entity_id = ws.uid' );
$pager_query->fields('fld_Country', array('field_counrty_tid'));
$pager_query->innerJoin('taxonomy_term_data ', 'taxonomy_Country', 'taxonomy_Country.tid = fld_Country.field_counrty_tid' );
$pager_query->addField('taxonomy_Country', 'name', 'tax_name');
Further down in the code is the section:
$result = $pager_query->execute();
$sids = array();
foreach ($result as $row) {
$sids[] = $row->sid;
$submissions[$row->sid] = new stdClass();
$submissions[$row->sid]->sid = $row->sid;
$submissions[$row->sid]->nid = $row->nid;
$submissions[$row->sid]->serial = $row->serial;
$submissions[$row->sid]->submitted = $row->submitted;
$submissions[$row->sid]->remote_addr = $row->remote_addr;
$submissions[$row->sid]->uid = $row->uid;
$submissions[$row->sid]->name = $row->name;
$submissions[$row->sid]->is_draft = $row->is_draft;
$submissions[$row->sid]->preview = FALSE;
$submissions[$row->sid]->data = array();
In this section I added the line:
$submissions[$row->sid]->CountryID = $row->tax_name;
To display the data, we now need to edit the webform.report.inc file. Find the section near the top that says,
foreach ($submissions as $sid => $submission) {
$row = array(
$submission->is_draft ? t('@serial (draft)', array('@serial' => $submission->serial)) : $submission->serial,
format_date($submission->submitted, 'short'),
);
if (webform_results_access($node, $user)) {
$row[] = theme('username', array('account' => $submission));
$row[] = $submission->remote_addr;
I then added the following line after the format_date section to add my new column after the submitted column.
$submission->CountryID,
To add the header for the new column find the section with the comment,
* Theme the header of the submissions table.
I then added the following line after the submitted section,
array('data' => t('Country'), 'field' => 'tax_name'),
Save both files and view a webform results page (providing it has a submission).
Your new column should now display.
I hope this helps anyone else that is confused on this subject!
Happy new year everyone!!!