Home  >  Article  >  Backend Development  >  radio的值如何写入数据库

radio的值如何写入数据库

WBOY
WBOYOriginal
2016-06-13 12:01:211809browse

radio的值怎么写入数据库

本帖最后由 lihui4512z 于 2014-07-03 17:21:43 编辑

其他几列都是动态获取的,都能够成功写入数据库。

现在问题就在这一句

<td style="text-align:center;font-size:14px;"><input type="radio" name="<?php echo $_values;?>" value="正常" style="zoom:150%;" />正常<br /><input type="radio" name="<?php echo $_values;?>" value="不正常" style="zoom:150%;" />不正常</td>


感觉name这样定义好像不对,但又不知道怎么弄了。请问怎样可以将radio选中的值写入数据库?name不好用常量。


附整个表单代码:














while (!!$_rows = _fetch_array_list($_result2)){
?>




<td style="text-align:center;font-size:14px;"><input type="radio" name="<?php echo $_values;?>" value="正常" style="zoom:150%;" />正常<br /><input type="radio" name="<?php echo $_values;?>" value="不正常" style="zoom:150%;" />不正常</td>


}?>

开始点检
车辆选择:
工号:日期:

编号点检项目点检方法点检标准状 态














【cldj.php】

<?php <br />header("Content-type: text/html; charset=utf-8");<br />require ('common.php');<br /><br />$hh=$_POST['hao1'];<br />$aa=$_POST['bh'];<br />$bb=$_POST['xm'];<br />$cc=$_POST['fangfa'];<br />$dd=$_POST['biaozhun'];<br />$_gh=$_COOKIE["name"]; <br />$_time=$_POST['time'];<br /><br />$name=implode(_fetch_array_list(mysql_query("SELECT name FROM jsy WHERE gonghao = $_gh")));<br /><br />if (is_array($aa)){<br />foreach ($aa as $i=>$v){<br /> mysql_query("INSERT INTO djjl (hao,bh,xm,fangfa,biaozhun,gonghao,name,time,zt) VALUES (<br />								'$hh',<br />                                                                '$v',								<br />								'{$bb[$i]}',<br />								'{$cc[$i]}',<br />								'{$dd[$i]}',<br />								'$_gh',<br />								'$name',<br />								'$_time'		<br />												<br />								)" )or die('SQL执行失败!'.mysql_error());}}<br />mysql_close();<br />_alert_location('添加成功!','ksdj.php');<br />?>

------解决方案--------------------
你那样定义name,后台还有重组数组格式。建议你这样定义name值:
name="post[$_rows['bh']]['bh']"
name="post[$_rows['bh']]['xm']"
这样每一行就是一个数组。
后面的radio也是一样, name="post[$_rows['bh']]['status']"
------解决方案--------------------
引用:
你那样定义name,后台还有重组数组格式。建议你这样定义name值:
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn