i want to display the output in the following format by using the following source code but the following source code shows error

Notice: Undefined offset: 0 in eval() (line 20 of /....----modules/php/php.module(80) : eval()'d code).

enter image description here

include_once(drupal_get_path('module', 'webform').'/includes/webform.submissions.inc');
$query = db_select('webform_submitted_data', 'u');
$query->fields('u', array('sid','nid','data'));
$results =$query->execute();

echo "<table>";
echo "<tr>";
echo "<th>  Profile Photo </th>";
echo "<th> Faculty  Name and Department  </th>";
echo  "</tr>";

if($record = $results->fetchAssoc())
$sid = $record['sid'];
$nid = $record['nid'];
$submission = webform_get_submission($nid,$sid);
echo "<tr>";
$val = $submission->data[15][0];

$query1 = db_select('file_managed', 'u');
$query1->fields('u', array('fid','filename'));
$results1 =$query1->execute();

if ($record1 = $results1->fetchAssoc())
$path = $record1['filename'];

echo "<td> <a href ='http://../content/detailed-information/?val=$sid'  target='_blank'><img src ='../profile/$path'   width = '100' height='100' /> </a> </td>";
echo "<td><b>" .  "Name : " . $submission->data[1][0] . "</b><br>" .  " Designation : " . $submission->data[2][0] . "<br>" . " Department : " . $submission->data[3][0] ."<br>" . " E-mail : " . $submission->data[4][0] .  "</td>"; 
echo "</tr>";
echo "</table>";


1 Answer 1


Just as it says, the error is in the line

$val = $submission->data[15][0];

so the variable $submission->data[15] does not contain a value [0]. Most likely the array is empty.

Of course, it's probably a bad idea to go to the database yourself, rather than using Webforms API functions. A little searching can get you started.

  • You've no idea how much time you saved me inadvertently. Thanks man!
    – user219492
    Jul 12, 2014 at 15:45
  • The site linked at the bottom of this answer is no longer active: drupalize.me/api-site
    – user1359
    Oct 13, 2014 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.