require '../model/class_connect_db.php'; require '../model/class_insert.php'; require '../model/class_delete.php'; require '../model/class_update.php'; if (isset($_POST['company'])) { $id_company = $_POST['company']; } if (isset($_POST['arr_data']) && !empty($_POST['arr_data'])) { if (is_array(json_decode($_POST['arr_data'])) && is_array(json_decode($_POST['arr_id']))) { $arr_id = json_decode($_POST['arr_id']); $arr_data = json_decode($_POST['arr_data']); $table = $_POST['table']; $field = $_POST['field']; $array = array_combine($arr_id, $arr_data); if (isset($_POST['delete'])) { $delete = new DeleteVar(); foreach ($array as $key => $value) { $delete->delete_var($key, $table); $delete->delete_var_prod($key, $field); } echo json_encode(true); return; } if (isset($_POST['save'])) { $update = new Update(); foreach ($array as $key => $value) { if ($table == 'roominess_mav' || $table == 'roominess_mob') { $int = (int) preg_replace("/[^0-9]/", '', $value); $sql = "UPDATE {$table} SET {$field}='{$value}', int_val='{$int}' WHERE id='{$key}'"; } else { $sql = "UPDATE {$table} SET {$field}='{$value}' WHERE id='{$key}'";
<?php require '../model/class_connect_db.php'; require '../model/class_delete.php'; if (isset($_POST['id_img'], $_POST['color_tent'])) { $obj_img = new DeleteVar(); $result = $obj_img->delete_var($_POST['id_img'], $_POST['table']); //$result = $_POST; echo json_encode($result); } if (isset($_POST['data'])) { $dir = "../img/" . $_POST['data']; $result = file_exists($dir); if ($result == true) { if (unlink($dir)) { echo json_encode(true); } } }
<?php require '../model/class_connect_db.php'; require '../model/class_delete.php'; //var_dump($_POST); if (isset($_POST['delete'], $_POST['table'])) { $id = intval($_POST['delete']); $table = $_POST['table']; $delete = new DeleteVar(); $result = $delete->delete_var($id, $table); if ($result == true) { if ($table == 'count_zakaz') { $delete->delete_var($id, $table); $delete->delete_count_zakaz($id); header("Location: ../pages/zakaz.php"); } if (isset($_POST['delcat'])) { $delete->delete_var_prod($id, "id_category"); } if ($table == 'opt') { header("Location: ../pages/opt.php"); } if ($table == 'zakaz') { $idz = $_POST['zakaz_id']; header("Location: ../pages/zakaz_view.php?zakaz_id={$idz}"); } if ($table == 'catalog_price') { $idz = $_POST['id_company']; header("Location: ../pages/products.php?id={$idz}"); } else { echo json_encode($result);