count the number of other attributes and pseudo-classes in the selector (= c)
$updatingFields = [];
foreach (['name', 'familia'] as $field) {
if (isset($_POST[$field]) && $fieldValue = trim($_POST[$field])) {
$updatingFields[] = sprintf("%s = '%s'", $field, $link->real_escape_string($fieldValue));
}
}
$result = null;
if (count($updatingFields)) {
$query = sprintf(
"
UPDATE users
SET %s
WHERE id = '%s'
",
implode(', ', $updatingFields),
$link->real_escape_string($id)
);
$result = $link->query($query);
}