Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.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
Javascript 动态文本框并保存在mysql中_Javascript_Php_Mysql - Fatal编程技术网

Javascript 动态文本框并保存在mysql中

Javascript 动态文本框并保存在mysql中,javascript,php,mysql,Javascript,Php,Mysql,我试图在动态文本框中添加我的资格详细信息,并将其存储在mysql中,但它不起作用。我可以添加详细信息,并且可以第一次存储详细信息,但是在编辑的情况下,我不能添加新数据。 同时,我有两个表,第一个是formdata,其中包含除资格之外的所有数据,第二个是资格表,其中仅包含资格详细信息,其中包含来自formdata的外键引用。谁来帮忙 编辑代码: <?php $query3=mysqli_query($conn, "select * from qualification wh

我试图在动态文本框中添加我的资格详细信息,并将其存储在mysql中,但它不起作用。我可以添加详细信息,并且可以第一次存储详细信息,但是在编辑的情况下,我不能添加新数据。 同时,我有两个表,第一个是formdata,其中包含除资格之外的所有数据,第二个是资格表,其中仅包含资格详细信息,其中包含来自formdata的外键引用。谁来帮忙

编辑代码:

<?php


     $query3=mysqli_query($conn, "select * from qualification where user_id='$id'");
                      while ($record = $query3->fetch_assoc())
                      {
                         $resultset[] = $record;
                      }
                      $rows = mysqli_affected_rows($conn);
                      for ($i=0;$i<$rows;$i++)
                      {
                        ?>

                        <input type="hidden" name="id[]" value="<?php echo $resultset["$i"]['id']; ?>" />
                        <tr id="textboxgroup<?php echo $i ?>">
                        <td>
                             <input type="text" name="instname[]" id="iname" class="group" value="<?php echo $resultset["$i"]['instname']; ?>"/>
                        </td>
                        <td>
                             <input type="text" name="year[]" id="year" class="group" value="<?php echo $resultset["$i"]['year']; ?>"/>
                        </td>
                        <td>
                             <input type="text" name="percentage[]" id="percentage" class="group" value="<?php echo $resultset["$i"]['percentage']; ?>"/>
                        </td>
                        <td>
                             <input type="button" name="add" id="add" value="+" onclick="addrow();"/>
                             <input type="button" name="remove" id="remove" value="-" onclick="remove(this);"/>
                        </td>
                      </tr>
                      <?php
                      }
                    ?>
                    <tr id="new"></tr>
                   </table>
                  <input type= "hidden" id="user_id" name="user_id" value="<?php echo $query2['user_id']; ?>"/>
                  <input type="submit" class="update" name="update" value="Update"/>
                  <input TYPE="button" class="back" value="Back" onclick="window.location.href='display1.php';"/> 
      </fieldset>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
    <script>
    function addrow(){
            var tr = $('#textboxgroup0').clone();
            tr.find('.group').val('');
            tr.insertBefore('#new');
    }
    function remove(obj)
         {
              var parentDiv = $(obj).parent().parent();
              if(parentDiv.attr('id') !== 'textboxgroup0') {
              parentDiv.remove();
              }
              if(parentDiv.attr('id') == 'textboxgroup0') {
              var tr = $('#textboxgroup0');
              tr.find('.group').val(''); }
         }
    </script>

您的问题不清楚。查询是否需要添加新行,您询问如何更新?您的
更新
查询在哪里?
 $instname = $_POST['instname'];
           $year = $_POST['year'];
           $percentage = $_POST['percentage'];
           $max = (count($_POST["year"]));
           $id1=$_POST['id'];
           for ($i=0; $i<$max; $i++)
           {
           $instname1 = $instname[$i];
           $year1 = $year[$i];
           $percentage1 = $percentage[$i];
           $id2=$id1[$i];
           $sql2= "INSERT INTO qualification(id, user_id, instname, year, percentage) VALUES ($id2, $id, $instname1, $year1, $percentage1) ON DUPLICATE KEY UPDATE user_id='$id', instname='$instname1', year='$year1', percentage='$percentage1' ";
           $qual = mysqli_query($conn,$sql2);
           }