better way using webform functions.
<?php
// set the table titles
$header = array('FIRST', 'LAST', 'COMMENT', 'ZIP', 'PHOTO');
// get data from webform_views_nestorwebform table
// this table is created by the webform_mysql_views module
// and it contains the data from a webform
$query = "SELECT first, last, comment, zip, photo FROM {webform_views_nestorwebform} where approved=1 ORDER BY first";
$q = db_query($query);
// move the returned array to $rows
while ($r = db_fetch_array($q)) {
$rows[] = $r;
}
for($i=0; $i<count($rows);$i++) {
foreach($rows[$i] as $key => $value) {
if($key == 'photo' && $value > 0) {
$fid=$value;
$myfile = db_fetch_object(db_query("SELECT * FROM {files} WHERE fid = %d", $fid));
$fname=$myfile->filename;
$fpath=$myfile->filepath;
$rows[$i][$key] = "<a href='$fpath'><img src='$fpath' width='50px' height='30px'></a><Br\n";
}
}
}
// the theme function automatically create the table title
// and display the data for the table
print theme('table', $header, $rows);
?>