douya2433 2018-11-30 06:59
浏览 51

如果在php ajax和html中遇到false语句,如果它在数组中,如何将值保存到数据库中?

I want to store the display value in a database as a row but only when the statement false. So I created this way to store but not sure about the declaration of each value for the column. I so confused about array and so on. I have this for loop in PHP to display in a table but not sure if this need to convert into an array.

      <?php 
      for($x=$str, $y=0; $y!=($endmo);$x++) {


         if ($w == 1){
            //has code here
          }
         else{

             //it will display value here in table
             $date = $x;
             $a = 8;
             $b = 3;
             $c = 4 ;
            //it will display value here
            //not sure if need to convert into array

           $ts = array("$date", "$a", "$b", "$c");
           $var = json_encode($ts);
           }
          $y++;
       }
       ?>

The idea is I just want to store the else value statement only. This will store the same value of a, b and c but different date when rendering this and this will save in row but we will save the value for each in a different column. This is my javascript code :

       <script>
          $(document).ready(function(){
         var mo = '<?php echo $mo; ?>';
         var yr = '<?php echo $yr; ?>';
         var obj = JSON.parse('<?= $var; ?>');

          //how to get all the value from php above

         $.ajax({
            type: "POST",
            dataType: "text",
            data: {'date':'date', 'mo': 'mo', 'yr': yr,'a': 'a', 'b': b, 'c': c},
            url: "save.php",
            success: function(data) {
                $('#rdft').html(data);
            }
        });
         }
            </script>

In save.php I will use the SQL statement to insert each value into the database.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP