使用Phpmysql或Javascript插入和更新多个复选框数据 [英] Insert And Update Multiple Checkbox Data Using Phpmysql Or Javascript

查看:71
本文介绍了使用Phpmysql或Javascript插入和更新多个复选框数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用PHPMYSQL或JAVASCRIPT插入和更新多个复选框数据




大家好


我想检查多个复选框,在重新访问该页面后更新它们。

我将这个名称作为name = type [] ..以array的形式...但是在检查结果时数据库简单地给出了世界''数组''。我希望同时检查和更新多个复选框..

和插入复选框值的查询必须包含在执行的查询中为表格的其余部分插入数据..


这是代码:


[PHP]

< ;?


包括dbconnect.php;

// error_reporting(''notice'');

if (isset($ _ POST [''submit'']))

{//处理表格

$ message = NULL;


$ type = $ _ POST [''type''];

$ query =" insert into form

(类型,其他,目的)VALUES(''$ type'',''$ other'',''$ purp ose'');


$ result = mysql_query($ query );


if(!$ result){die(mysql_error());}

else {echo''Record Inserted'';}} br />


< form action ="<?php echo $ _SERVER [''PHP_SELF''];?>"方法= QUOT;交" >< table width =" 90%" align = center cellpadding = 2 class = medium>

< tbody>

< tr>

< td width =" 42 %">< font color ="#333333"大小= QUOT 1 QUOT;

face =" Verdana,Arial,Helvetica,sans-serif">< br>

< input type = checkbox name = type [] value = Logo /小册子和GT;


Logo / Brochure< / font>< / td>

< td>< font color ="#333333"大小= QUOT 1 QUOT;

face =" Verdana,Arial,Helvetica,sans-serif">< br>

< input type = checkbox value =软件/ Web应用程序开发名称=键入[]>

软件/网络应用程序开发< / font>< / td>

< / tr>

< tr>

< td width =" 42%">< font color ="#333333"大小= QUOT 1 QUOT;

face =" Verdana,Arial,Helvetica,sans-serif">< br>

< input type = checkbox value = CD presentation name = type [ ]>

CD演示文稿< / font>< / td>

< td>< font color ="#333333"大小= QUOT 1 QUOT;

face =" Verdana,Arial,Helvetica,sans-serif">< br>

< input type = checkbox value = 2D / 3D animations name =输入[]>

2D / 3D动画< / font>< / td>

< / tr>

< tr> ;

< td>< font color ="#333333"大小= QUOT 1 QUOT;

face =" Verdana,Arial,Helvetica,sans-serif">< br>


< input type = checkbox value = Web banner / intro name = type []>

Web Banner / Intro< / font>< / td>

< td>< font color ="#333333"大小= QUOT 1 QUOT;

face =" Verdana,Arial,Helvetica,sans-serif">< br>

< input type = checkbox value = E-learning name = type []>

电子学习< / font>< / td>

< / tr>

< tr>

< td>< p>< font color ="#333333"大小= QUOT 1 QUOT;

face =" Verdana,Arial,Helvetica,sans-serif">< br>

如果是其他,请说明:< / font>< / p>< / td>

< td valign = bottom>< div align = right>< font color ="#333333"大小= QUOT 1 QUOT;

face =" Verdana,Arial,Helvetica,sans-serif">

< input name =" other类型= QUOT;文本"大小= QUOT; 50" value ="<?php if(isset($ _ POST [''other'']))echo($ _ POST [''other''])?>" >

< / font>< / div>< / td>

< / tr>

< / tbody> ;

< / table>< / form> [/ PHP]

如果解决方案在javascript中仍然可以和我一起使用


所以这是复选框的代码...如果有任何解决方案..plz发布它


Thanx和问候

TechnoAtif

解决方案

_POST [''submit'']))

{//处理表格

消息= NULL;


type =


INSERT AND UPDATE MULTIPLE CHECKBOX DATA USING PHPMYSQL OR JAVASCRIPT




Hi All

I want to check the multiple checkboxes update them after revisiting that page.
I am taking the name as name=type[]..in the form of array..but on checking it the result in the database simply gives the world ''array''.i want multiple checkboxes to be checked and updated simultaneously..
and the query to insert the checkbox value has to be included along with the query performed to insert data for rest of the form..

Here is the code:

[PHP]
<?

include "dbconnect.php";
//error_reporting(''notice'');
if(isset($_POST[''submit'']))
{//handle the form
$message=NULL;

$type=$_POST[''type''];
$query ="insert into form
(type,other,purpose)VALUES(''$type'',''$other'',''$purp ose'');

$result =mysql_query($query);

if(!$result){die(mysql_error());}
else {echo ''Record Inserted'';}



<form action="<?php echo $_SERVER[''PHP_SELF''];?>" method="post" ><table width="90%" align=center cellpadding=2 class=medium>
<tbody>
<tr>
<td width="42%"><font color="#333333" size="1"
face="Verdana, Arial, Helvetica, sans-serif"><br>
<input type=checkbox name=type[] value=Logo/Brochure>

Logo/Brochure </font></td>
<td><font color="#333333" size="1"
face="Verdana, Arial, Helvetica, sans-serif"><br>
<input type=checkbox value= Software/Web application development name=type[]>
Software/Web Application Development</font></td>
</tr>
<tr>
<td width="42%"><font color="#333333" size="1"
face="Verdana, Arial, Helvetica, sans-serif"><br>
<input type=checkbox value=CD presentations name=type[]>
CD presentations</font></td>
<td><font color="#333333" size="1"
face="Verdana, Arial, Helvetica, sans-serif"><br>
<input type=checkbox value=2D/3D animations name=type[]>
2D/3D animations</font></td>
</tr>
<tr>
<td><font color="#333333" size="1"
face="Verdana, Arial, Helvetica, sans-serif"><br>

<input type=checkbox value= Web banner/intro name=type[]>
Web Banner/Intro</font></td>
<td><font color="#333333" size="1"
face="Verdana, Arial, Helvetica, sans-serif"><br>
<input type=checkbox value=E-learning name=type[]>
E-learning </font></td>
</tr>
<tr>
<td><p><font color="#333333" size="1"
face="Verdana, Arial, Helvetica, sans-serif"><br>
If other, please explain: </font></p></td>
<td valign=bottom><div align=right><font color="#333333" size="1"
face="Verdana, Arial, Helvetica, sans-serif">
<input name="other" type="text" size="50" value="<?php if(isset($_POST[''other''])) echo($_POST[''other''])?>" >
</font></div></td>
</tr>
</tbody>
</table></form>[/PHP]
If the solution is in javascript still its fine with me

So this is the code for checkbox...if any have the solution..plz post it

Thanx and Regards
TechnoAtif

解决方案

_POST[''submit'']))
{//handle the form


message=NULL;


type=


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

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