0){ $sql = "SELECT client_id FROM requisitions WHERE id = {$req_id}"; $q = mysql_query($sql); if($r = mysql_fetch_assoc($q)){ $client_id = (int)$r['client_id']; } } if ($options = Docs::getSourcesList($get['agency_id'], $get['section'], $required)) { foreach ($options as $option) { $name = $option['name']; $selected = ''; if ($get['section'] == "clients") { $contacts = []; if($option['id'] == $client_id) $selected = 'selected'; if (!empty($option['email'])) $contacts[] = $option['email']; if (!empty($option['phone'])) $contacts[] = $option['phone']; if (!empty($contacts)) $name .= ' (' . implode(', ', $contacts) . ')'; } else { if (!empty($option['address'])) $name .= ' (' . $option['address'] . ')'; } $output[] = ''; } } echo implode("\r\n", $output); }