使用php和mysql编辑表单

时间:2018-07-10 20:57:17

标签: php mysql edit

我想在MYSQL中编辑数据。但它给出了一个错误,我找不到这个。下面的代码是为了使编辑成为可能。谢谢您的答复

if (isset($_POST['update']))
{ 
    include $_SERVER["DOCUMENT_ROOT"] . "/EZ2XS/testopdracht/html/config.php";

    $tag            = $_POST['tag'];
    $nr             = $_POST['nr'];
    $reference      = $_POST['reference'];
    $scores         = $_POST['scores'];
    $evaluates      = $_POST['evaluates'];
    $observations   = $_POST['observations'];
    $conform        = $_POST['conform'];
    $reports        = $_POST['reports'];
$query = "UPDATE `afwijking` SET 

    `tag`           ='$tag',
    `nr`            ='$nr',
    `reference`     ='$reference',
    `scores`        ='$scores',
    `evaluates`     ='$evaluates',
    `observations`  ='$observations',
    `conform`       ='$conform',
    `reports`       ='$reports',
     WHERE `ID`.`ID' = '1';";

    $result = mysqli_query($conn, $query);

    if ($conn->query($query) === TRUE)
    {
       echo 'DATA Updated';

    } else {
        echo 'DATA NOT UPDATED';
    }
    mysqli_close($conn);
}  

在这里,我的桌子就是从myqsl获取他的信息

while($row = mysqli_fetch_array($records))
{
    echo "<tr><form method=post>";
    echo "<td><input type=text name=tag value='".$row['tag']."'></td>";
    echo "<td><input type=text name=nr value='".$row['nr']."'></td>";
    echo "<td><input type=text name=reference value='".$row['reference']."'></td>";
    echo "<td><input type=text name=scores value='".$row['scores']."'></td>";
    echo "<td><input type=text name=evaluates value='".$row['evaluates']."'></td>";
    echo "<td><input type=text name=observations value='".$row['observations']."'></td>";
    echo "<td><input type=text name=reports value='".$row['reports']."'></td>";
    echo "<td><input type=text name=conform value='".$row['conform']."'></td>";
    echo "<input type=hidden name=id value='".$row['ID']."'>";
    echo "<td><input type=submit name=update>";
    echo "</form></tr>";
}   

0 个答案:

没有答案