$database = new Database();
$array_sql = '';
$array_sql = array(
array('sql_colum' => 'fl_select', 'val' => $fl_checkbox),
array('sql_colum' => 'price_fl_ignor_1с', 'val' => $price_fl_ignor_1с),
array('sql_colum' => 'price_fl_nalichie', 'val' => (int)$_POST['fl_nalichie']),
array('sql_colum' => 'price_fl_add_corzina', 'val' => (int)$_POST['add_corzina']),
array('sql_colum' => 'price_tip', 'val' => 'price'),
array('sql_colum' => 'price_articul', 'val' => clear_string($_POST["articul"])),
array('sql_colum' => 'price_shtrih_kod', 'val' => clear_string($_POST["shtrih_kod"])),
array('sql_colum' => 'price_obem', 'val' => clear_string($_POST["obem"])),
array('sql_colum' => 'price_strana', 'val' => clear_string($_POST["strana"])),
array('sql_colum' => 'price_new', 'val' => (int)$_POST['price_new']),
array('sql_colum' => 'price_star', 'val' => (int)$_POST['price_star']),
array('sql_colum' => 'price_data', 'val' => (int)$_POST['price_data']),
array('sql_colum' => 'price_data_ot', 'val' => clear_string($_POST["data_ot"])),
array('sql_colum' => 'price_data_do', 'val' => clear_string($_POST["data_do"])),
);
//print_r($array_sql);
$sql_colin=''; $sql_colin2 = '';
for($i = 0; $i < count($array_sql); ++$i) {
$sql_colin .= $array_sql[$i]['sql_colum'].'=:'.$array_sql[$i]['sql_colum'].',';
$sql_colin2 .= $array_sql[$i]['sql_colum']."='".$array_sql[$i]['val']."',";
}
$SQL = "UPDATE tovar__price SET ".chop($sql_colin, ',')." WHERE id=:id";// chop позволяет отрезать все до запятой с зади строки
$SQL_err = "UPDATE tovar__price SET ".chop($sql_colin2, ',')." WHERE id=".(int)$_POST['id'];
$database->prepare($SQL);
for($i = 0; $i < count($array_sql); ++$i) {$sql_colum = $array_sql[$i]['sql_colum'];$val = $array_sql[$i]['val'];$database->bind(":$sql_colum",$val);}
$database->bind(":id", (int)$_POST['id']);
$database->execute();
IF ($database->error){echo $database->error;}else{
echo 'Все хорошо';
echo $SQL_err;
}