50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
include('includes/functions.php');
|
|
include('log_entry.php');
|
|
error_log("Start Printing Request Attributes");
|
|
$requestStr = "";
|
|
foreach ($_REQUEST as $key => $value) {
|
|
$requestStr .= $key . " : " . $value . "\n";
|
|
error_log($key . " : " . $value . "<br />\r\n");
|
|
}
|
|
error_log("End Printing Request Attributes");
|
|
save_log($requestStr, 'Save Deivce Map', 'SAVE', 'save_device_map.php');
|
|
|
|
$noOfRows = $_POST['count_items'];
|
|
error_log("noOfRows" . $noOfRows);
|
|
begin();
|
|
|
|
|
|
$link_id = $_POST['link_id'];
|
|
|
|
$data = array();
|
|
|
|
|
|
|
|
// clear existing entries into the table
|
|
if (!empty($link_id)) {
|
|
$query_del = " delete from device_param_map where link_id = '" . $link_id . "' ";
|
|
|
|
error_log("delete query " . $query_del);
|
|
}
|
|
|
|
$result_del = @mysqli_query($conn, $query_del);
|
|
|
|
for ($i = 0; $i < $noOfRows; $i++) {
|
|
|
|
|
|
$query1 = "insert into device_param_map set checkup_parameter_id ='" . ${"param_id$i"} . "',device_param_code = '" . ${"code$i"} . "',device_id='" . ${"device$i"} . "', modified_by = '" . $_SESSION['user_id'] . "' ";
|
|
|
|
error_log("query1" . $query1);
|
|
if (!$result1 = @mysqli_query($conn, $query1)) {
|
|
|
|
rollback();
|
|
header('HTTP/1.1 500 Internal Server Error');
|
|
echo json_encode(die('failed!' . mysqli_error($conn)));
|
|
}
|
|
}
|
|
commit();
|
|
|
|
echo json_encode($data);
|