Take the 2-minute tour ×

Can anyone give me an insight into what I'm doing wrong, please?

I have a webform of 32 components and I am trying to create XML of the submitted data. The form has been filled and submitted just once.

$query  =   db_select('webform_submitted_data', 'wsd');
$query->join('webform_component', 'wc', 'wsd.cid = wc.cid');

$query->fields('wsd', array('nid', 'cid', 'data', 'sid'));
$query->fields('wc', array('form_key', 'name'));


As you can see, I am performing a join between 2 tables inorder to get the form_key for each filled webform component.

The problem is I get alot more that 32 results - somehow the result is going badly wrong.

share|improve this question
add comment

1 Answer

up vote 8 down vote accepted

If you are trying to get the submission data, you can use the webforms api to retrieve all submissions for a particular webform with the webform_get_submissions function. Then you can parse through the data for each submission to build your XML.

$submissions = webform_get_submissions(array('nid'=>$webform_nid));

foreach ($submissions as $submission){
    foreach ($submission->data as $row=>$data){
share|improve this answer
Thanks Mike. I just updated your code slightly by adding the 'includes' directory before webform.submissions –  sisko Oct 8 '12 at 9:25
ahh, thanks for that. –  mmiles Oct 8 '12 at 13:26
add comment

Your Answer


