Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
未更新phpmyadmin数据库表_Php_Mysql_Ajax - Fatal编程技术网

未更新phpmyadmin数据库表

未更新phpmyadmin数据库表,php,mysql,ajax,Php,Mysql,Ajax,我正在使用php、Ajax和MySQL。提交表单时,数据库表中的数据不会更新。我被困在这里了。谁能告诉我如何解决这个问题??提前谢谢各位。代码如下: 更新_details.php <form id="form6" name="form6" method="post"> <div class="row"> <h4 style="font-size: 16px;padding-left: 15px;"><b>Benefits Deliver

我正在使用php、Ajax和MySQL。提交表单时,数据库表中的数据不会更新。我被困在这里了。谁能告诉我如何解决这个问题??提前谢谢各位。代码如下:

更新_details.php

<form id="form6" name="form6" method="post">
  <div class="row">
    <h4 style="font-size: 16px;padding-left: 15px;"><b>Benefits Delivered by Local People from Plantation Felling:</b></h4><br>
    <div class="col-sm-6">
      <div align="right" style="padding-right: 10px;">
        <label style="font-weight:300;font-size: 15px;margin-top:5px; ">Dependence of Local People on the Site:
        </label>
        <select name="dependence_of_local_people" id="dependence_of_local_people" style="width:30%;height: 30px; margin-left: 10px; border-radius: 5px;margin-top:5px; ">
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
        </select><br><br>
      </div>
    </div>
    <div class="col-sm-4">
      <div align="right" style="padding-right: 10px;">
        <label style="font-weight:300;font-size: 15px;">Wage Income:</label>
        <input type="text" name="wage_income" id="wage_income" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
      </div>
    </div>
    <div class="col-sm-2">
      <div align="right" style="padding-right: 0px;">
        <input class="btn btn-info btn-submit6" type="submit" name="submit5" value="Update" onclick="move5()">
      </div>
    </div>
  </div>
</form>
<script>
    jQuery(document).ready(function() {
        $('.btn-submit6').click(function(e) {
            e.preventDefault();
            $.ajax({
                url:"modify_func.php",
                method:"POST",
                data:$('#form6').serialize(),
                success:function(data)
                {
                    document.getElementById("form6").reset();
                }
            });
        });
    });
</script>
修改_func.php

    <?php
$con=mysqli_connect("localhost","root","","forestdb");
if(isset($_POST['dependence_of_local_people'])){
    $plantation_journal_no=$_GET['id'];
    $dependence_of_local_people=$_POST['dependence_of_local_people'];
    $wage_income=$_POST['wage_income'];
    $sql="UPDATE `benefits_derived` SET `dependence_of_local_people`='$dependence_of_local_people',`wage_income`='$wage_income' WHERE `plantation_journal_no`='$plantation_journal_no'";

    $result=mysqli_query($con,$sql);
}
?>
我认为通过使用$_GET['id'];您试图获取某个url参数,该参数出现在显示表单的url中,但您使用jquery提交表单,因此$planture\u journal\u no=$\u get['id'];无法在代码中工作,因为未设置$\u GET['id']

试试这个:

$('.btn-submit6').click(function(e) {
        e.preventDefault();
        $.ajax({
            url:"modify_func.php",
            method:"POST",
            data:$('#form6').serialize() + '&id=<?php echo $_GET['id']; ?>',
            success:function(data)
            {
                document.getElementById("form6").reset();
            }
        });
    });

如果您打印\u r$\u POST;你有什么发现吗?@Michael没有,我什么都没有。按提交按钮会发生什么?你的控制台里有什么?尝试console.log每一步你想从哪里获取$planture\u journal\u no?在$sql=。。。并检查查询语句。正如@JashParekh提到的,你的$planture\u journal\u no=$\u GET['id']似乎是错的。因此,您的Update子句将在WHERE部分失败。HTML和JS似乎可以工作。
$plantation_journal_no=$_POST['id'];