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).
<?php
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'));
$query->condition('nid','159','=');
$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>";
echo $val = $submission->data[15][0];
}
?>