PHP代码没有获取更新数据库的ID

时间:2017-08-29 23:39:11

标签: php html mysqli

我的代码下面没有获取更新数据库的ID。 该ID位于来自其他网页表单的网页网址上。 屏幕上没有显示错误,但我的数据库没有更新。

我错过了什么吗?

FactoryGirl.create_list(:question, 5) do |question|
   question.answers = FactoryGirl.build_list(:answer)
   # or...
   # question.answers.create(FactoryGirl.attributes_for(:answer))
end

1 个答案:

答案 0 :(得分:0)

感谢您的帮助。我发现了这个问题! 正如你所说的Kiko,我试图回应循环中的任何地方,问题一直在继续。 现在我在开始时更改了代码并解决了问题。

以下是解决方案:

<?php

if($_GET['id']){
$id = $_GET["id"];
$product_name = $_POST["product_name"];
$visible = $_POST["visible"];

    $query  = "UPDATE products SET ";
    $query .= "product_name = '{$product_name}', ";
    $query .= "visible = {$visible} ";
    $query .= "WHERE id = $id ";
    $result = mysqli_query($connection, $query);
}
?>
相关问题