fetching records from webform_submitted_data table through following source code but showing error How to display the records from the table by using the following source code?


  Notice: Undefined offset: 0 in eval() (line 20 of /var/www/module(80)
  : eval()'d code).


&lt;?php
include_once(drupal_get_path('module', 'webform').'/includes/webform.submissions.inc');
$query = db_select('webform_submitted_data', 'u');
$query-&gt;fields('u', array('sid','nid','data'));
$query-&gt;condition('nid','159','=');
$results =$query-&gt;execute();

echo "&lt;table&gt;";
echo "&lt;tr&gt;";
echo "&lt;th&gt;  Profile Photo &lt;/th&gt;";
echo "&lt;th&gt; Faculty  Name and Department  &lt;/th&gt;";
echo  "&lt;/tr&gt;";

if ($record = $results-&gt;fetchAssoc())
{
$sid = $record['sid'];
$nid = $record['nid'];
$submission = webform_get_submission($nid,$sid);
echo "&lt;tr&gt;";
echo $val = $submission-&gt;data[15][0];
}
?&gt;
Try below code,

You can retrieve node webform all submissions using  webform_get_submissions which accepts an array of filters.. As per the error you mentioned in the question seems like below code is causing problem

echo $val = $submission-&gt;data[15][0];


I would suggest printing the information that you got before you try to fetch the data so that you know you are correclty accessing the array results.. print_r will assist you to see the results..

module_load_include('inc','webform','includes/webform.submissions');
$submissions = webform_get_submissions(array('nid'=&gt; 159));

foreach ($submissions as $submission){
    foreach ($submission-&gt;data as $row=&gt;$data){
        print '&lt;pre&gt;';print_r($row);print '&lt;/pre&gt;';
        print '&lt;pre&gt;';print_r($data);print '&lt;/pre&gt;';
    }
}


Extract the information you want from $row and $data ...