I don't know how to connect do DB2, but I guess MS-SQL is similar (or equal) to MySQL and it might help you on that.
$db_conn = mysql_connect ($sql_host, $sql_user, $sql_pass) or die ('I cannot connect to the database');
mysql_select_db ($my_db);
$q = mysql_query("Select * from mytable");
while($found = mysql_fetch_array($q)) {
print $found['field1'];
print $found['field2'];
print $found['field2'];
.
.
.
}