相同的语法,但一个不起作用。有什么区别?

时间:2017-11-05 00:17:27

标签: php

我有两个几乎相同的PHP文件 - 第一个正确更新相应的表,第二个没有。我犯了什么错误?也没有抛出任何错误。当我提交第二个表单时,表单会刷新,但是不会对其各自的表进行任何更改。

第一个样本(适当地运作)

@Test
@WithMockUser(roles = "USER")
public void loginWithRoleUserThenExpectUserSpecificContent() throws Exception {
    mockMvc.perform(get("/index"))
            .andExpect(status().isOk())
            .andExpect(content().string(containsString("This content is only shown to users.")));
}

第二个样本(不起作用的那个)

<?php
include 'formTop.php'
;?>

    <div class="formInput">
        <p class="ph1" style="font-size: 30">Edit Current Unit</p>
        <h5 class="ph5">Edit Unit Board Form</h5>
        <hr>

    <?php

        $issue_ID = $_GET['idx'];
        $mysqli = new mysqli('localhost', 'root', '', 'disolDemo');
        $query = $mysqli->query("SELECT * FROM delayboard WHERE issue_ID = '$issue_ID' LIMIT 0,1") or die($msqli->error);
        $row = $query->fetch_assoc();
        if(isset($_POST['update'])){
            $issue_ID = $_POST['issue_ID'];
            $delay_ID = $_POST['delay_ID'];
            $delayDate = $_POST['delayDate'];
            $delayTime = $_POST['delayTime'];
            $delayNote = $_POST['delayNote'];
            $result = $mysqli->query("UPDATE delayboard SET delay_ID = '$delay_ID', delayDate = '$delayDate', delayTime = '$delayTime', delayNote = '$delayNote' WHERE issue_ID='$issue_ID'");
        }
    ?>

    <div class="formInput">
    <form method='POST'>
        <div class="formAlign">
        <p class="pInput">Issue ID :</p> <input type='text' id='issue_ID' name='issue_ID' value="<?php echo $row['issue_ID']?>" readonly>
        <br/>
        <p class="pInput">Delay ID :</p> <input type='text' id='delay_ID' name='delay_ID' value="<?php echo $row['delay_ID']?>" readonly>
        <br/>
        <p class="pInput">Delay Date :</p> <input type='text' id='delayDate' name='delayDate' value="<?php echo $row['delayDate']?>" >
        <br/>
        <p class="pInput">Delay Time :</p> <input type='text' id='delayTime' name='delayTime' value="<?php echo $row['delayTime']?>" >
        <br/>           
        <p class="pInput">Delay Note :</p> <input type='text' id='delayNote' name='delayNote' value="<?php echo $row['delayNote']?>">
        <br/>
                        <input type='submit' value='update' name='update' style="margin-bottom: 25px; margin-top: -25px; margin-left: auto; margin-right: auto;">
        </div>

    </form>
    </div>

<?php
include 'formBottom.php'
;?>

1 个答案:

答案 0 :(得分:0)

感谢大家的时间,但我找到了我的错误 - 我应该通过我唯一的主键选择行,在上面的例子中是display_ID和note_ID。相反,我根据我的issue_ID选择进行编辑,并且存在重复的issue_ID&(我的外键)的条目。我应该从一开始就这样做。由于存在重复的issue_ID,因此未对表进行更改。