选择选项更新时未定义的索引

时间:2019-03-12 13:17:18

标签: php mysql

为什么我的选择选项有未定义的索引,尽管在插入时没有错误,我尝试进行isset和!empty,但是它们对我的选项有任何价值,有人可以启发我为什么我在那部分出错但我没有问题我的插入代码仅在更新中。并告诉我为什么我对更新模式的选择选项未定义,而我的添加或插入则没有错误。没有发布未定义的索引吧?

<form action="categoryedit.php" method="post">
    <div class="row clearfix">
        <div class="form-group">
            <div class="form-line">
                <label>Category No.:</label>
                <input type="text" onkeydown="return alphaOnly(event);" class="form-control" value="<?php echo $categoryno ?>" name="editcategoryno" value="" required autofocus  />
            </div>
        </div>
        <div class="form-group">
            <div class="form-line">
                <label>Category:</label>
                <input type="text" class="form-control" value="<?php echo $genre ?>" name="editgenre" required  />
            </div>
        </div>

        <div class="form-group">
            <div class="form-line">
                <label>Circulation Type:</label>
                <!--     <input type="text" class="form-control" value="<?php echo $section ?>" name="editsection" required  /> -->
                <select name="editsection" class="form-control">
                    <option value="<?php echo $section ?>"><?php echo $section; ?></option>     <option value="<?php if ($section == 'Filipiniana Section') {
                        # code...
                        echo "General Circulation Section";
                    }elseif ($section == 'General Circulation Section') {
                        # code...
                        echo "Filipiniana Section";
                    } ?>"><?php if ($section == 'Filipiniana Section') {
                        # code...
                        echo "General Circulation Section";
                    }elseif ($section == 'General Circulation Section') {
                        # code...

                        echo "Filipiniana Section";
                    } ?></option>
                </select>
            </div>
        </div>



    </div>




</div>

<div class="modal-footer">
    <input type="hidden" name="id" value="<?php echo $id ?>"   />
    <input type="submit" name="submit" class="btn btn-info" value="Submit" />
    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>

</div>

</form>

这是我的categoryedit.php

if (isset($_POST['submit'])) {
    $categoryno = mysqli_real_escape_string($connect, $_POST['editcategoryno']);
    $id = mysqli_real_escape_string($connect, $_POST['id']);
    $genre = mysqli_real_escape_string($connect, $_POST['editgenre']);
    $editsection = mysqli_real_escape_string($connect, $_POST['editsection']);
    $searchsql = mysqli_query($connect, "SELECT * FROM category WHERE categoryno = '$categoryno' AND categoryno = '$genre' AND section = '$editsection' ");
    if (mysqli_num_rows($searchsql) == 0) {
        # code...

        $updatequery = mysqli_query($connect, "UPDATE category SET categoryno = '$categoryno', genre = '$genre', section = '$editsection' WHERE id = '$id'");
        if ($updatequery) {
            # code...
            echo "<script>
            alert('Succesfully Update The Category');
            </script>";
        }


    }elseif (mysqli_num_rows($searchsql) != 0) {
        # code...
        echo "<script>
        alert('Already Have This Category No.');
        </script>";
    }

}

0 个答案:

没有答案