thinkphp复选框数组如何同其他数据写入一条数据中
Array([tmid]=>1[values]=>Array([0]=>无水氨010066[1]=>氩010082)...
Array ( [tmid] => 1 [values] => Array ( [0] => 无水氨010066 [1] => 氩010082 )
展开
展开全部
1、php部分如下:
<?php
//print_r($_POST);
foreach($_POST['chk'] as $val) {
mysql_query("insert into xxx (uname) values('{$val}')");
}
?>
2、HTML部分如下:
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<input type="checkbox" name="chk[]" value="11" />
<input type="checkbox" name="chk[]" value="22" />
<input type="checkbox" name="chk[]" value="33" />
<input type="checkbox" name="chk[]" value="44" />
<input type="radio" name="ds" value="55" checked="checked" />
<input type="radio" name="ds" value="66" />
<input type="submit" />
</form>
<?php
//print_r($_POST);
foreach($_POST['chk'] as $val) {
mysql_query("insert into xxx (uname) values('{$val}')");
}
?>
2、HTML部分如下:
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<input type="checkbox" name="chk[]" value="11" />
<input type="checkbox" name="chk[]" value="22" />
<input type="checkbox" name="chk[]" value="33" />
<input type="checkbox" name="chk[]" value="44" />
<input type="radio" name="ds" value="55" checked="checked" />
<input type="radio" name="ds" value="66" />
<input type="submit" />
</form>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询