简体   繁体   English

我怎样才能保存我的价值<input type='checkbox'>使用 Laravel 5.7 代码到 MySQL 数据库?

[英]How can I save the value of my <input type='checkbox'> to MySQL Database with laravel 5.7 code?

checkbox复选框

 <div class="form-check"> <input type="checkbox" name="IF" class="form-check-input"> <label for="IF" class="form-check-label">Ingénieurie de formation</label> <input type="checkbox" name="DS" class="form-check-input"> <label for="DS" class="form-check-label">Diagnostique Stratégique</label> <input type="checkbox" name="PF" class="form-check-input"> <label for="PF" class="form-check-label">Plan de formation</label> </div>


and for my textbox I store it like this对于我的文本框,我是这样存储的

$cl = new Client;
$cl->tel_1 = $request->input('tel_1');

You are getting the value wrong, the index is the name attribute in html:你得到的值错误,索引是 html 中的name属性:

$cl->tel_1 = $request->input('IF');

or或者

<input type="checkbox" name="tel_1" class="form-check-input"> and $cl->tel_1 = $request->input('tel_1'); <input type="checkbox" name="tel_1" class="form-check-input">$cl->tel_1 = $request->input('tel_1');

Use value of name attribute from checkbox.使用复选框中的名称属性值。

$checkbox1 = Input::get('IF') //name="IF" $checkbox1 = Input::get('IF') //name="IF"

also, do not forget to add.另外,不要忘记添加。

use Illuminate\\Support\\Facades\\Input;使用 Illuminate\\Support\\Facades\\Input;

You can either use您可以使用

$cl->tel_1 = $_POST['IF'];

Or you can use或者你可以使用

$cl->tel_1 = $_REQUEST['IF'];

as well.以及。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将具有多个字段的动态输入保存到数据库Laravel 5.7 - How can I save dynamic input with multiple fields to database Laravel 5.7 如何将复选框值保存到数据库Laravel - How to save checkbox value to database Laravel 如何将“值”字段的值放入数据库中输入类型为复选框的形式? - how can i put the value of “value” field in a form where input type is checkbox from database? 如何在MySQL数据库中保存jquery keyup()的每个输入值? - How can I save each input value of a jquery keyup() in MySQL database? 如何将复选框开关中的值发送到 MySQL 数据库 - How can I send a value from a checkbox switch to a MySQL database 如何避免在返回 Laravel 5.7 数据库层中的主键的结果上使用 `array_map`? - How I can avoid using `array_map` on my results returning primary keys in Laravel's 5.7 database layer? 如何使用PHP将复选框值保存到mysql数据库中 - how to save checkbox value into mysql database using php 如何将复选框值保存到数据库中 - how to save checkbox value into database 我想知道如何在我的数据库Mysql5.7中获取一些字段,而无需在控制器中使用fakerr技术(laravel) - I would like to know how I can get some fields in my db Mysql5.7 without using the faker technique in my controller (laravel) 如何从组件 Vue.js 和 Laravel 的数据库中获取复选框中的选定值? - How can i get the selected value in checkbox from database in component Vue.js with Laravel?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM