php - 提交后数据库表中的值未更新

标签 php jquery mysql ajax mysqli

我是 PHP 新手。当我尝试更新或修改我的表单时,它不会在 phpmyadmin 数据库表中更新。我正在使用 AJAX、jQuery 和 PHP。我被严重困在这里,所以任何人都可以指导我如何解决这个问题。提前致谢。以下是代码。

update_details.php

<div class="panel-body">
                        <?php 
                            $q1="SELECT * FROM `plantation_journal_basic_details` WHERE `plantation_journal_no`='$plantation_journal_no' ";
                            $r1=mysqli_query($con,$q1);
                            $ro1=mysqli_fetch_array($r1);
                         ?>
                        <form id="form1" action="update_details.php?id='<?php echo $plantation_journal_no; ?>'" name="form1" method="post">
                        <div class="row">
                            <div class="col-sm-4">
                                <h4 style="font-size: 16px;"><b>Basic Details:</b></h4><br>
                                <div  align="right" style="padding-right: 10px;" >
                                    <div  align="right" style="padding-right: 10px;" >
                                    <label style="font-weight:300;font-size: 15px">Scheme:</label>
                                    <label align="left" style="width:50%;margin-left: 10px;font-weight:300;font-size: 15px"><?php echo $ro1['scheme']; ?></label><br><br>
                                    <label style="font-weight:300;font-size: 15px">Year:</label>
                                    <label align="left" style="width:50%;margin-left: 10px;font-weight:300;font-size: 15px"><?php echo $ro1['year']; ?></label><br><br>
                                    <label style="font-weight:300;font-size: 15px">Range:</label>
                                    <label align="left" style="width:50%;margin-left: 10px;font-weight:300;font-size: 15px"><?php echo $ro1['ranges']; ?></label><br><br>
                                    <label style="font-weight:300;font-size: 15px">Beat:</label>
                                    <label align="left" style="width:50%;margin-left: 10px;font-weight:300;font-size: 15px"><?php echo $ro1['beat']; ?></label><br><br>
                                    <label style="font-weight:300;font-size: 15px">JFMC:</label>
                                    <label align="left" style="width:50%;margin-left: 10px;font-weight:300;font-size: 15px"><?php echo $ro1['jfmc']; ?></label><br><br>
                                    <label style="font-weight:300;font-size: 15px">Panchayat Samity:</label>
                                    <label align="left" style="width:50%;margin-left: 10px;font-weight:300;font-size: 15px"><?php echo $ro1['panchayat_samity']; ?></label><br><br>
                                    <label style="font-weight:300;font-size: 15px">Gram Panchayat:</label>
                                    <label align="left" style="width:50%;margin-left: 10px;font-weight:300;font-size: 15px"><?php echo $ro1['gram_panchayat']; ?></label><br><br>
                                </div>
                            </div>
                        </div>
                            <div class="col-sm-4">
                                <h4 style="font-size: 16px;"><b>GPS Coordinates:</b></h4><br>
                                <div  align="right" style="padding-right: 10px;" >
                                    <label style="font-weight:300;font-size: 15px">Latitude:</label>
                                    <input type="text" name="latitude_degree" value="<?php echo $ro1['latitude_degree']; ?>"  style="width:10%;height: 30px; margin-left: 10px; border-radius: 5px; padding: 0 0 0 1px;">
                                    <label style="font-weight:300;font-size: 15px">°</label>
                                    <input type="text" name="latitude_minute" value="<?php echo $ro1['latitude_minute']; ?>"  style="width:10%;height: 30px; margin-left: 10px;  padding: 0 0 0 1px; border-radius: 5px;">
                                    <label style="font-weight:300;font-size: 15px">'</label>
                                    <input type="text" name="latitude_second" value="<?php echo $ro1['latitude_second']; ?>"  style="width:10%;height: 30px; margin-left: 10px; border-radius: 5px;  padding: 0 0 0 1px;">
                                    <label style="font-weight:300;font-size: 15px">"</label><br>
                                    <label style="font-weight:300;font-size: 15px">Longitude:</label>
                                    <input type="text" name="longitude_degree" value="<?php echo $ro1['longitude_degree']; ?>"  style="width:10%;height: 30px; margin-left: 10px; border-radius: 5px; padding: 0 0 0 1px;">
                                    <label style="font-weight:300;font-size: 15px">°</label>
                                    <input type="text" name="longitude_minute"  value="<?php echo $ro1['longitude_minute']; ?>" style="width:10%;height: 30px; margin-left: 10px; border-radius: 5px; padding: 0 0 0 1px;">
                                    <label style="font-weight:300;font-size: 15px">'</label>
                                    <input type="text" name="longitude_second" value="<?php echo $ro1['longitude_second']; ?>"  style="width:10%;height: 30px; margin-left: 10px; border-radius: 5px; padding: 0 0 0 1px;">
                                    <label style="font-weight:300;font-size: 15px">"</label><br>
                                </div>
                                <h4 style="font-size: 16px;"><b>Boundary:</b></h4><br>
                                <div  align="right" style="padding-right: 10px;" >
                                    <label style="font-weight:300;font-size: 15px">North:</label>
                                    <input type="text" name="north" value="<?php echo $ro1['north']; ?>"  style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
                                    <label style="font-weight:300;font-size: 15px">East:</label>
                                    <input type="text" name="east" value="<?php echo $ro1['east']; ?>" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
                                    <label style="font-weight:300;font-size: 15px">West:</label>
                                    <input type="text" name="west" value="<?php echo $ro1['west']; ?>" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
                                    <label style="font-weight:300;font-size: 15px">South:</label>
                                    <input type="text" name="south" value="<?php echo $ro1['south']; ?>"  style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
                                </div>
                            </div>
                            <div class="col-sm-4">
                                <h4 style="font-size: 16px;"><b>Surveyed By:</b></h4><br>
                                <div  align="right" style="padding-right: 10px;" >
                                    <label style="font-weight:300;font-size: 15px">Full Name:</label>
                                    <input type="text" name="full_name_s" value="<?php echo $ro1['ful_name_s']; ?>"  style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
                                    <label style="font-weight:300;font-size: 15px">Designation:</label>
                                    <input type="text" name="designation_s" value="<?php echo $ro1['designation_s']; ?>"  style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
                                </div>
                                <h4 style="font-size: 16px;"><b>Checked By:</b></h4><br>
                                <div  align="right" style="padding-right: 10px;" >
                                    <label style="font-weight:300;font-size: 15px">Full Name:</label>
                                    <input type="text" name="full_name_c"  value="<?php echo $ro1['full_name_c']; ?>" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
                                    <label style="font-weight:300;font-size: 15px">Designation:</label>
                                    <input type="text" name="designation_c"  value="<?php echo $ro1['designation_c']; ?>" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
                                </div>
                            </div>
                        </div>
                        <br>
                        <div align="right">
                            <input class="btn btn-info btn-submit8" type="submit" name="submit_1" value="Add" onclick="move1()">
                        </div>
                    </form>
                    <?php 
                            if(isset($_POST['latitude_degree'])){
                            $latitude_degree=$_POST['latitude_degree'];
                            $latitude_minute=$_POST['latitude_minute'];
                            $latitude_second=$_POST['latitude_second'];
                            $longitude_degree=$_POST['longitude_degree'];
                            $longitude_minute=$_POST['longitude_minute'];
                            $longitude_second=$_POST['longitude_second'];
                            $north=$_POST['north'];
                            $east=$_POST['east'];
                            $west=$_POST['west'];
                            $south=$_POST['south'];
                            $full_name_s=$_POST['full_name_s'];
                            $designation_s=$_POST['designation_s'];
                            $full_name_c=$_POST['full_name_c'];
                            $designation_c=$_POST['designation_c'];
                            $sql="UPDATE `plantation_journal_basic_details` SET `latitude_degree`='$latitude_degree',`latitude_minute`='$latitude_minute',`latitude_second`='$latitude_second',`longitude_degree`='$longitude_degree',`longitude_minute`='$longitude_minute',`longitude_second`='$longitude_second',`north`='$north',`east`='$east',`west`='$west',`south`='$south',`ful_name_s`='$full_name_s',`designation_s`='$designation_s',`full_name_c`='$full_name_c',`designation_c`='$designation_c' WHERE `plantation_journal_no`='$plantation_journal_no'";

                            $result=mysqli_query($con,$sql);
                            }
                         ?>

最佳答案

提交所有输入值的更简单方法是:

$('#form').ajaxForm({
    /*....*/
});

你尝试过吗?

关于php - 提交后数据库表中的值未更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50781523/

相关文章:

php - jQuery 数据表将日期显示为 [object Object]

mysql - magic_quotes_gpc 开启时是否需要使用 mysql_real_escape_string()?

java - 使用 Java 谈论网络上的一些项目?

php - 本地主机在更新到 Maverick/Yosemite OS 后不执行 php 文件

javascript - jQuery动态添加内容到div

javascript - 如何用 .each 替换标签内容

javascript - 我如何读取 Web 服务的以下 json 响应?

php - 为什么此更新用户密码的代码不起作用?

MySQL Workbench Export Completed with 1 Errors - 如何查看错误?

php - 如何从我的脚本中获取网站的 Google 排名?