if(isset($banda1) && !empty($banda1))
{
$sql = "UPDATE banda SET banda1=:banda1 WHERE b_id=:b_id";
query($sql, [':banda'=>$banda, 'b_id'=>$b_id]);
}
if(isset($banda2) && !empty($banda2)){
$sql = "UPDATE banda SET banda2=:banda2 WHERE b_id=:b_id";
query($sql, [':banda'=>$banda, 'b_id'=>$b_id]);
}
//..............
///.......
$updateQuery = [];
$queryValues = ['b_id' => $b_id];
for($i = 1; $i <= 16; $i++){
if(isset($_POST["band" . $i])){
$bandName = "band" . $i;
$updateQuery[] = $bandName . "=:" . $bandName;
$queryValues[$bandName] = $_POST[$bandName];
}
}
if($updateQuery){
$query = "UPDATE bands SET " . implode(', ', $updateQuery) . " WHERE b_id = :id";
query($query, $queryValues);
}