我的pdo更新抗议未更新到数据库

时间:2018-07-25 16:37:37

标签: php forms pdo sql-update

我正在尝试从数据库中获取行并将其更新回一个php文件中

这是我尝试过的

    <?php
         include 'init.php';
       if (isset($_POST["pch"])) {
    $change  = $_POST["change"];
    $records = $conn->prepare("select * from newpin where code= :book");
    $records->bindParam(':book', $change);
    $records->execute();
    if ($records->rowCount() < 1) {
        echo "no data exit";
        exit();
    }
    while ($prow = $records->fetch(PDO::FETCH_BOTH)) {
        $id  = $prow["id"];
        $tdp = $prow["recharge"];
        if (isset($_POST["add"])) {
            $put = $_POST["put"];
            $go  = $conn->prepare("update newpin set recharge=:put where code=:diot");
            $go->bindParam(":put", $put);
            $go->bindParam(":diot", $id);
            $go->execute();
            echo success;
        }
        echo "<form action='#' method='POST'>
Edit Number
<input type='text' name='put' value='$tdp'/>
<input type='submit' name='add' value='Change'/>
</form>
</div>";
        }
        }
       echo '<form action="#" method="POST">
Edit Number
<input type="text" name="change" value="change_now"/>
<input type="submit" name="pch" value="Change"/>
</form>
</div>';
       ?>

我从数据库中成功获取了数据,但是在将其更新回来时却不正确,我做错了什么

0 个答案:

没有答案