PHP set field-name with parameter

Solution 1:

You have to whitelist the values of $field and concatenate it into the query:

if (in_array($field, array('allowed_field_1', 'allowed_field_2'))) {
  $sql = "UPDATE STA_Kunden SET " . $field . " = ? WHERE (KUN_KundeNo = ?)";
  $params = array($value, $select);
}