Редактирование записей таблицы на сайте поиска

Проблема заключается в том, что при изменении и нажатии на кнопку "сохранить" информация не обновляется.

Задумка-то в том, чтобы на странице поиска отредактировать и обновить информацию на нажатие кнопки.

При нажатии на кнопку выдает:

"Record updated successfully
string(174) "UPDATE infprintedit SET id='', title='', author='', year='',publisher='',compedit='',countpages='',archive='',bbk='',inventnumber='',numbinstances='',lasttaker='' WHERE id=''""

findoper.php

<?php
session_start();
require_once "vendor/connect.php";
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <script src="https://code.jquery.com/jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60=" crossorigin="anonymous"></script>
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <link rel="stylesheet" type="text/css" href="style/style.css">
    <script src="script.js"></script>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Научно-справочная библиотека</title>
</head>

<body>
    <style>
        td {
            font-size: large;
        }
    </style>


    <?php
    if (isset($_SESSION['user'])) {
        echo "<h1>" . $_SESSION['user']['login'], "," . $_SESSION['user']['role'] . ".</h1>";
    }
    ?>
    <form id="search" method="POST" action="findoper.php">
        <div style="display:flex; flex-direction: row; justify-content: center; align-items: center;">
            <div class="info">
                <label>Название:</label>
                <input type="text" name="search[title]">
            </div>
            <div class="info">
                <label>Автор:</label>
                <input type="text" name="search[author]">
            </div>
            <div class="info">
                <label>Под редакцией:</label>
                <input type="text" name="search[compedit]">
            </div>
            <div class="info">
                <label>Год:</label>
                <input type="text" name="search[year]" style="height:30px; width:60px;">
            </div>
            <div class="info">
                <input type="submit" name="submit" value="Поиск" style="height:30px; width:120px; background-color: white">
            </div>
    </form>
    <div class="info">
        <form action="mainpageoper.php">
            <input type="submit" name="SubmitForm" value="Назад" style="height:30px; width:120px; background-color: white">
        </form>
    </div>
    <br>
    <br>
    <div class="info">
        <form action="vendor/logout.php">
            <input type="submit" name="SubmitForm" value="Выход" style="height:30px; width:120px; background-color: white">
        </form>
    </div>
    </div>
    <?php
    $queryCondition = "";
    if (!empty($_POST)) {
        $submitForm = $_POST["submitForm"];
        foreach ($_POST["search"] as $key => $value) {
            if (isset($value)) {
                if (empty($queryCondition)) {
                    $queryCondition = " WHERE ";
                } else {
                    $queryCondition .= " AND ";
                }
                $queryCondition .= "$key LIKE '%" . $value . "%'";
            }
        }
    }
    $sql = "SELECT `id`,`title`, `author`, `year`, `publisher`, `compedit`,`countpages`,`archive`,`BBK`,`inventnumber`,`numbinstances`,`lasttaker` FROM infprintedit " . $queryCondition;
    $result = mysqli_query($connect, $sql);
    $res = mysqli_fetch_all($result, MYSQLI_ASSOC);
    $rowsCount = $result->num_rows; // количество полученных строк
    echo "<table><tr><th>Название</th><th>Автор</th><th>Год</th><th>Издательство</th><th>Под редакцией</th><th>Количество страниц</th><th>Архив</th><th>ББК</th><th>Инвентарный номер</th><th>Количество экземпляров</th><th>Кто последний пользовался</th><th>Действие</th></tr>";
    foreach ($result as $row) {
    ?>
        <tr>
            <td contentEditable='true'>
                <?php echo $row["title"]; ?>
            </td>
            <td contentEditable='true'>
                <?php echo $row["author"]; ?>
            </td>
            <td contentEditable='true'>
                <?php echo $row["year"]; ?>
            </td>
            <td contentEditable='true'>
                <?php echo $row["publisher"]; ?>
            </td>
            <td contentEditable='true'>
                <?php echo $row["compedit"]; ?>
            </td>
            <td contentEditable='true'>
                <?php echo $row["countpages"]; ?>
            </td>
            <td contentEditable='true'>
                <?php echo $row["archive"]; ?>
            </td>
            <td contentEditable='true'>
                <?php echo $row["BBK"]; ?>
            </td>
            <td contentEditable='true'>
                <?php echo $row["inventnumber"]; ?>
            </td>
            <td contentEditable='true'>
                <?php echo $row["numbinstances"]; ?>
            </td>
            <td contentEditable='true'>
                <?php echo $row["lasttaker"]; ?>
            </td>
            <td>
                <form action="vendor/update.php"> <input type="submit" name="edit" value="Сохранить" style="background-color: white" ></form>
            </td>
        </tr>
    <?
    }
    echo "</table >";
    $result->free();
    ?>
    
    <br>
</body>

</html>

update.php

<?php
session_start();
require_once 'connect.php';
$title = $_POST['title'];
$author = $_POST['author'];
$year = $_POST['year'];
$publisher = $_POST['publisher'];
$compedit = $_POST['compedit'];
$countpages = $_POST['countpages'];
$archive = $_POST['archive'];
$bbk = $_POST['bbk'];
$inventnumber = $_POST['inventnumber'];
$numbinstances = $_POST['numbinstances'];
$lasttaker = $_POST['lasttaker'];
$sql=("UPDATE infprintedit SET id='" . $_POST['id'] . "', title='" . $_POST['title'] . "', author='" . $_POST['author'] . "', year='" . $_POST['year'] . "',publisher='" . $_POST['publisher'] . "',compedit='" . $_POST['compedit'] . "',countpages='" . $_POST['countpages'] . "',archive='" . $_POST['archive'] . "',bbk='" . $_POST['bbk'] . "',inventnumber='" . $_POST['inventnumber'] . "',numbinstances='" . $_POST['numbinstances'] . "',lasttaker='" . $_POST['lasttaker'] . "' WHERE id='" . $_POST['id'] . "'");
    if(mysqli_query($connect,$sql)){
        echo "Record updated successfully";
    }else {
        echo "Error updating record: " . mysqli_error($connect);
    }
    mysqli_close($connect);


echo '<pre>';
var_dump($sql);
echo '</pre>';

Ответы (0 шт):