Seems like the long way to get the arrat, but as-is, you can do this...
// replace
$result2 = mysql_query("select username from work_on where pid in ('$result1_array')");
// with this
$sql = "SELECT username FROM work_on WHERE pid IN (";
for($i=0;$i<count($result1_array);$i++) {
if($i==0) {
$sql .= "'".$result1_array[$i][0]."'";
}
else {
$sql .= ", '".$result1_array[$i][0]."'";
}
}
$sql .= ")";
$result2 = mysql_query($sql);