选中复选框插入或更新到数据库(mySQL) [英] Checkbox checked insert or update to database(mySQL)

查看:414
本文介绍了选中复选框插入或更新到数据库(mySQL)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果选中复选框= 1 else = 0,我怎么能声明复选框。

在插入或更新数据库之后,在数据库中只有1和0代表已选中和未选中。



< input type =checkboxid =homepagename =homepagevalue =1/> 



这是我的复选框代码,它尚未声明。



P / S:我正在使用PHP代码编写。我是php的新手。



谢谢

问候。

解决方案

< blockquote>我将向您展示一个可以适应您需求的示例。

在html表单中:

 <  表格   操作  =  nameofphpscript.php   方法  =  post >  
想回家吗?
< 输入 < span class =code-attribute> type = 复选框 id = 主页 名称 = 主页 value = 1 / >
< input type = 提交 名称 = formSubmit value = 提交 / >
< span class =code-keyword>< / form >



 <?php  


status = ' 0';

if(isset(


_POST [' 主页'])&&


How could I declared checkbox, if checkbox checked = 1 else = 0.
After that insert or update to database,in the database will only 1 and 0 represent checked and unchecked.

<input type="checkbox" id="homepage" name="homepage" value="1" />


This my checkbox code,it haven't declared.

P/S: I'm using PHP code writing. And I'm newbie for php.

Thanks
Regards.

解决方案

I will show you an example that you can adapt to your need.
In the html form:

<form action="nameofphpscript.php" method="post">
    Want to go home?
    <input type="checkbox" id="homepage" name="homepage" value="1" />
    <input type="submit" name="formSubmit" value="Submit" />
</form>



in the 'nameofphpscript.php' file:

<?php


status = '0'; if(isset(


_POST['homepage']) &&


这篇关于选中复选框插入或更新到数据库(mySQL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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