BOOLEAN值进入MYSQL数据库 [英] BOOLEAN values into MYSQL database

查看:333
本文介绍了BOOLEAN值进入MYSQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在下面创建一个表单 - 如果选中复选框为TRUE或FALSE(BOOLEAN),则插入MYSQL数据库



I有以下但我不知道如何将其输入数据库?



我尝试过:



Hi I am creating a form below - in which inserts into MYSQL database if the checkbox is checked as TRUE or FALSE (BOOLEAN)

I have the below but I'm not sure how I can get it into the database?

What I have tried:

<h1>Question 1</h1><br>
 </br>
  <input type="checkbox" name="B1" value="">Milk
  <input type="checkbox" name="B2" value="">Cheese
  <input type="checkbox" name="B3" value="" >Yogurt
  <input type="checkbox" name="B4" value="">Eggs
  <input type="checkbox" name="B5" value="">Beans

推荐答案

您必须发送表单数据到PHP脚本(参见 PHP:处理表格 - 手册 [ ^ ])。



在PHP脚本中读取上述链接中描述的数据并采取相应措施。对于数据库访问,请使用 PHP:MySQLi - Manual [ ^ ]。





要确定复选框的状态,请检查是否设置了相应的数据:

You have to send the form data to a PHP script (see PHP: Dealing with Forms - Manual[^]).

Within your PHP script read the data as described in the above link and act accordingly. For database access use PHP: MySQLi - Manual[^].


To determine the state of a checkbox, check if the corresponding data is set:


b1 = FALSE;
if (isset(
b1 = FALSE; if (isset(


_POST [' B1'])){
_POST['B1'])) {


这篇关于BOOLEAN值进入MYSQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆