Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/56.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
Php 保存其他列的数据_Php_Mysql - Fatal编程技术网

Php 保存其他列的数据

Php 保存其他列的数据,php,mysql,Php,Mysql,我为许多选择下拉列表设置了多个带有基本价格的表。我想在用户选择他们想要的价格后,将所有这些合并到一个表中。我遇到的问题是,我正在使用每个表的数字字段(房间)来填充他们可以选择的下拉列表的数量 正在填充下拉列表的表 id room area pr_clean pr_protectant pr_sanitizer pr_deodorizer 1 1 Area 8.95 19.95 17.95

我为许多选择下拉列表设置了多个带有基本价格的表。我想在用户选择他们想要的价格后,将所有这些合并到一个表中。我遇到的问题是,我正在使用每个表的数字字段(房间)来填充他们可以选择的下拉列表的数量

正在填充下拉列表的表

id  room      area     pr_clean   pr_protectant   pr_sanitizer    pr_deodorizer
1   1        Area      8.95      19.95             17.95            7.5
2   2        Areas     17.9      39.9              35.9             15
3   3        Areas     26.85     59.85             53.85            22.5
4   4        Areas     35.8      79.8              71.8             30
5   5        Areas     39.95     99.75             89.75            37.5
6   6        Areas     53.7      119.7             107.7            45
7   Whole House Areas  69.95     139.65            125.65           52.5
选择下拉列表为:

<select name="rooms" id="Areas"> 
     <option value="" selected="selected">0</option>
          @foreach ($room as $rooms)
             <option data-price="{{ $rooms->pr_clean }}" value='{{ $rooms->room  }}'>{{ $rooms->room  }}</option>
          @endforeach
</select>


the data is saving like this via my php controller: 

                $input = [
                        Input::get('rooms')
                ];
//                 echo '<pre>';
//                var_dump($input); die;

                foreach($input as $services)
                {
                    $service = new Service();

                    $service->userID = $user->id;
                    $service->services = $services;

                    $service->save();
                }

我需要根据下拉列表中的值填充“服务”列和“价格”列。而不是将值本身放入“服务”列

如何保存?用表格?您需要将pr_clean coloun的值保存到price coloun,以及该值,用户选择了哪个房间?是的,我很抱歉缺少该信息。是的,它以表单形式显示,然后转到控制器。。{{Form::open(数组('name'=>'服务','action'=>'BookController@showServices’)}…是的,基本上我需要服务栏中的“面积”(基于房间栏)和另一个表的价格栏中要保存的价格。当然,如果您使用表单,则有to方法、get方法和post方法。所以,如果用户提交一个表单,您需要获得一个$\u get或$\u POST数组,其中包含所有表单元素的数据和该值。在您的例子中,如果使用post方法:$\u post['rooms'],则会得到一个值。现在,如果它是uniqe,您可以在SQL表中搜索它,并读取价格。如果没有,则为select创建一个onchange事件,并使用一个hide-input-change事件读取数据price并放入hide-input元素。我认为,您无法在提交时获得数据-*值。
id  userID  services    price   created_at  updated_at
156 1           6     NULL  2013-09-08 01:14:26 2013-09-08 01:14:26
157 1           3     NULL  2013-09-08 01:14:26 2013-09-08 01:14:26