html - thinkphp3.2.3+mysql problem
漂亮男人
漂亮男人 2017-05-24 11:33:35
0
4
598

The front end is designed like this


Then click to add a summary and there will be one more line


# If this continues, you can have as many entries as you want. How can I use thinkphp to solve this problem of inserting into the database? Because it was fixed before, but now it is not fixed. I don’t know how to deal with this and insert it into the database. Thanks

Hello, how do I add database fields? Because the database fields are fixed, but now there are more and more input boxes on the front end. How to deal with this?

漂亮男人
漂亮男人

reply all(4)
大家讲道理

//Add data in batches

$data = M("Data");
$dataList[] = array('name'=>'name','email'=>'email');
$dataList[] = array('name'=>'name','email'=>'email');
$data->addAll($dataList);
迷茫

Thanks for the invitation, just organize it into a two-dimensional array and submit it as mentioned above

曾经蜡笔没有小新

Based on your comment, it seems that the main table cannot be moved, then add a table,
For example, array('name'=>'name','email'=>'email') is the main table It is permanently saved. After saving, there will be an ID. You can save this ID, together with other newly added fields, to another table, and then query it in conjunction with the table when displaying.

洪涛
          $old_array=$_POST;
          $new_array=array();
          foreach($old_array as $key=>$value){
          for($i=0;$i<=count($old_array[$key])-1;$i++){
          foreach(array_keys($old_array) as $k=>$v){
          $new_array[$i][$v]=$old_array[$v][$i];
          }
          }
          break;
          }

            $data=M('order')->addAll($new_array);   
            
            这个是插入数据
            如果你要做可以插入表字段的话就用
            key  value  键值对应的表来存数据
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template