Как я могу обновить все данные в этой форме?

Вот система в PHP, которая содержит информацию о категориях из базы данных. Я реализовал удаление, но запрос обновления не работает, может ли кто-нибудь помочь мне разобраться в ошибке?

код ниже:

<?php // ob_start(); ?>
<?php
    if (isset($_GET['update'])) {
        $post_id = $_GET['update'];
        $query = "select * from posts where post_id = {$post_id}";
        $select_categories = mysqli_query($connection, $query);

        while ($row = mysqli_fetch_assoc($select_categories)) {
            $post_id = $row['post_id'];
            $post_category_id = $row['post_category_id'];
            $post_title = $row['post_title'];
            $post_author = $row['post_author'];
            $post_date = $row['post_date'];
            $post_image = $row['post_image'];
            $post_content = $row['post_content'];
            $post_tags = $row['post_tag'];
            $post_comment_count = $row['post_comment_count'];
            $post_status = $row['post_status'];
        }
    }
?>

<?php
    if (isset($_POST['subs'])) {
        $post_authors = $_POST['post_author'];
        $post_statuss = $_POST['post_status'];
        $post_tagss = $_POST['post_tags'];
        $post_contents = $_POST['post_content'];
        $post_titles = $_POST['post_title'];
        $post_category = $_POST['post_category'];
        $post_images = $_FILES['image']['name'];
        $post_image_temp = $_FILES['image']['tmp_name'];

        move_uploaded_file($post_image_temp, "../image/$post_image");

        $queries = "update posts set post_category_id = '{$post_category}' post_title = '{$post_titles}', post_author = '{$post_authors}', post_date = now(), post_image = '{$post_image}', post_content = '{$post_contents}', post_tag='{$post_tags}', post_comment_count='{$post_comment_count}', post_status = '{$post_status}' where post_id = {$post_id}";

        $update_post = mysqli_query($connection, $queries);

        if (!$update_post)
            echo "Stupid";
    }
?>

<form action="posts.php" method="post" enctype="multipart/form-data">

    <div class="form-group">
        <label for="title">Post title</label>
        <input value="<?php if (isset($post_title)){ echo $post_title;} ?>" type="text" class="form-control" name="post_title">
    </div>

    <div class="form-group">
        <label for="title">Post Category Id</label>
        <br>
        <select name="post_category" id=""> <!-- post_category is the one that takes the value -->
        <?php
        if (isset($_GET['update'])) {
            $cat_ids = $_GET['update'];
            $query = "select * from categories";
            $select_categories = mysqli_query($connection, $query);

            confirm($select_categories);

            while ($row = mysqli_fetch_assoc($select_categories)) {
                $cat_id = $row['cat_id'];
                $cat_title = $row['cat_title'];

                echo "<option value='{$cat_id}'>{$cat_title}</option>";
            }
        }
        ?>
        </select>

    </div>

    <div class="form-group">
        <label for="title">Post Author</label>
        <input value="<?php if (isset($post_author)){ echo $post_author;} ?>" type="text" class="form-control" name="post_author">
    </div>

    <div class="form-group">
        <label for="title">Post Status</label>
        <input value="<?php if (isset($post_status)){ echo $post_status;} ?>" type="text" class="form-control" name="post_status">
    </div>

    <div class="form-group">
        <label for="title">Post Image</label>
        <img width="100" src="../images/<?php echo $post_image; ?>" alt="">
        <input type="file" name="image">
    </div>

    <div class="form-group">
        <label for="title">Post Tags</label>
        <input value="<?php if (isset($post_tags)){ echo $post_tags;} ?>" type="text" class="form-control" name="post_tags">
    </div>

    <div class="form-group">
        <label for="title">Post Content</label>
        <textarea class="form-control" name="post_content" id="" cols="30" rows="10"><?php if (isset($post_content)){ echo $post_content;} ?></textarea>
    </div>

    <div class="form-group">
        <input class="btn btn-primary" type="submit" name="subs" value="Update">
    </div>

</form> 

Работы: 1. Удаление ссылок одним кликом

  1. Форма будет извлечена из БД, и все значения будут показаны в определенном поле

  2. Пользователь может обновить

  3. Значения будут возвращены в db, как только будет нажата кнопка «Обновить».

Пожалуйста, помогите мне обновить ..

php,web,web-deployment,web-deployment-project,

0
Яндекс.Метрика