Я вывожу данные из таблицы reestr на страницу в виде таблицы в форму. При нажатии на кнопку изменить форма становится редактируемой. Пользователь редактирует данные и нажимает сохранить. Данные отправляются POST-запросом. Я принимаю данные и записываю в sql. Ошибок нет, все как будто хорошо, но данные в таблице sql не изменяются. Подскажите, что не так. Может есть лучшее решение данной задачи?
Вот форма и отправка данных:
if($result = mysqli_query($conn, $sql)) {
foreach($result as $row) {
$id = $row["id"];
$name = $row["name"];
$shore = $row["shore"];
$p1_pl = $row["p1_pl"];
$p1_gor = $row["p1_gor"];
$t1_pl = $row["t1_pl"];
$t1_gor = $row["t1_gor"];
$dop_sek = $row["dop_sek"];
$ekran = $row["ekran"];
$toob_vstr = $row["toob_vstr"];
$toob_vinos = $row["toob_vinos"];
$ks2 = $row["ks2"];
$ks1 = $row["ks1"];
$ks3 = $row["ks3"];
$g_obr = $row["g_obr"];
$tumb = $row["tumb"];
$uzs = $row["uzs"];
$tvp = $row["tvp"];
$usdk = $row["usdk"];
$type_kont = $row["type_kont"];
$type_lock = $row["type_lock"];
$appert = $row["appert"];
$power_so = $row["power_so"];
$power_so20 = $row["power_so20"];
$lenght = $row["lenght"];
$material = $row["material"];
$power_dk = $row["power_dk"];
$losses_u = $row["losses_u"];
$point = $row["point"];
$phone = $row["phone"];
$knd = $row["knd"];
$organisation = $row["organisation"];
$postavka = $row["postavka"];
$organisation_statement = $row["organisation_statement"];
?>
<tr>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $id;?>" name = "id"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $name;?>" name = "name"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $shore;?>" name = "shore"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $p1_pl;?>" name = "p1_pl"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $p1_gor;?>" name = "p1_gor"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $t1_pl;?>" name = "t1_pl"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $t1_gor;?>" name = "t1_gor"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $dop_sek;?>" name = "dop_sek"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $ekran;?>" name = "ekran"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $toob_vstr;?>" name = "toob_vstr"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $toob_vinos;?>" name = "toob_vinos"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $ks2;?>" name = "ks2"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $ks1;?>" name = "ks1"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $ks3;?>" name = "ks3"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $g_obr;?>" name = "g_obr"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $tumb;?>" name = "tumb"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $uzs;?>" name = "uzs"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $tvp;?>" name = "tvp"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $usdk;?>" name = "usdk"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $type_kont;?>" name = "type_kont"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $type_lock;?>" name = "type_lock"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $appert;?>" name = "appert"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $power_so;?>" name = "power_so"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $power_so20;?>" name = "power_so20"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $lenght;?>" name = "lenght"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $material;?>" name = "material"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $power_dk;?>" name = "power_dk"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $losses_u;?>" name = "losses_u"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $point;?>" name = "point"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $phone;?>" name = "phone"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $knd;?>" name = "knd"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $organisation;?>" name = "organisation"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $postavka;?>" name = "postavka"></td>
<td class = "td"><input class ="input_table" type="text" disabled form = "text" value = "<?= $organisation_statement;?>" name = "organisation_statement"></td>
<td class = "td"><p class='submit'><a href='?del={$id}'>Удалить</a></p></td>
</tr>
<?php
}
($result);
} else {
echo "Ошибка: " . mysqli_error($conn);
}
?>
<div class="buttonsEdit">
<button class="btnEdit" enable>Изменить</button>
<button class="btnSaveEdit" name="successful" type="submit" form="text" disabled>Сохранить</button>
<button class="btnCancelEdit" disabled>Отменить</button>
</div>
</div>
<script src="edit.js"></script>
<?php
if(isset($_POST["name"])) {
echo $_POST["name"];
$id = mysqli_real_escape_string($conn, $_POST["id"]);
$name = mysqli_real_escape_string($conn, $_POST["name"]);
$shore = mysqli_real_escape_string($conn, $_POST["shore"]);
$p1_pl = mysqli_real_escape_string($conn, $_POST["p1_pl"]);
$p1_gor = mysqli_real_escape_string($conn, $_POST["p1_gor"]);
$t1_pl = mysqli_real_escape_string($conn, $_POST["t1_pl"]);
$t1_gor = mysqli_real_escape_string($conn, $_POST["t1_gor"]);
$dop_sek = mysqli_real_escape_string($conn, $_POST["dop_sek"]);
$ekran = mysqli_real_escape_string($conn, $_POST["ekran"]);
$toob_vstr = mysqli_real_escape_string($conn, $_POST["toob_vstr"]);
$toob_vinos = mysqli_real_escape_string($conn, $_POST["toob_vinos"]);
$ks2 = mysqli_real_escape_string($conn, $_POST["ks2"]);
$ks1 = mysqli_real_escape_string($conn, $_POST["ks1"]);
$ks3 = mysqli_real_escape_string($conn, $_POST["ks3"]);
$g_obr = mysqli_real_escape_string($conn, $_POST["g_obr"]);
$tumb = mysqli_real_escape_string($conn, $_POST["tumb"]);
$uzs = mysqli_real_escape_string($conn, $_POST["uzs"]);
$tvp = mysqli_real_escape_string($conn, $_POST["tvp"]);
$usdk = mysqli_real_escape_string($conn, $_POST["usdk"]);
$type_kont = mysqli_real_escape_string($conn, $_POST["type_kont"]);
$type_lock = mysqli_real_escape_string($conn, $_POST["type_lock"]);
$appert = mysqli_real_escape_string($conn, $_POST["appert"]);
$power_so = mysqli_real_escape_string($conn, $_POST["power_so"]);
$power_so20 = mysqli_real_escape_string($conn, $_POST["power_so20"]);
$lenght = mysqli_real_escape_string($conn, $_POST["lenght"]);
$material = mysqli_real_escape_string($conn, $_POST["material"]);
$power_dk = mysqli_real_escape_string($conn, $_POST["power_dk"]);
$losses_u = mysqli_real_escape_string($conn, $_POST["losses_u"]);
$point = mysqli_real_escape_string($conn, $_POST["point"]);
$phone = mysqli_real_escape_string($conn, $_POST["phone"]);
$knd = mysqli_real_escape_string($conn, $_POST["knd"]);
$organisation = mysqli_real_escape_string($conn, $_POST["organisation"]);
$postavka = mysqli_real_escape_string($conn, $_POST["postavka"]);
$organisation_statement = mysqli_real_escape_string($conn, $_POST["organisation_statement"]);
$sql1 = "UPDATE reestr SET id='$id',name='$name',shore='$shore',p1_pl='$p1_pl',p1_gor='$p1_gor',t1_pl='$t1_pl',t1_gor='$t1_gor', dop_sek='$dop_sek',ekran='$ekran',toob_vstr='$toob_vstr',toob_vinos='$toob_vinos',ks2='$ks2',ks1='$ks1',ks3='$ks3',g_obr='$g_obr', tumb='$tumb',uzs='$uzs',tvp='$tvp',usdk='$usdk',type_kont='$type_kont',type_lock='$type_lock',appert='$appert',power_so='$power_so', power_so20='$power_so20',lenght='$lenght',material='$material',power_dk='$power_dk',losses_u='$losses_u',point='$point',phone='$phone',knd='$knd', organisation='$organisation',postavka='$postavka',organisation_statement='$organisation_statement' WHERE id=='$id'";
$res = mysqli_query($conn, $sql1);
if($res) {
var_dump("Данные сохранены");
}
}
($res)
?>