how to fetch webform records from table by using drupal db_select
Just as it says, the error is in the line

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


so the variable $submission-&gt;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.