时间:2021-07-01 10:21:17 帮助过:4人阅读
$_POST['a'] = array(1,2,3,4,5);$_POST['b'] = array('a','b','c','d','e');$_POST['c'] = array('男','女','女','男','男');$_POST['d'] = array(25,26,27,26,26);foreach($_POST['a'] as $i=>$v) { $sql = "inser into tbl_name values('$v', '{$_POST['b'][$i]}', '{$_POST['c'][$i]}', '{$_POST['d'][$i]}')"; echo $sql, PHP_EOL;}inser into tbl_name values('1', 'a', '男', '25')
$_POST['a'] = '1,2,3,4,5';$_POST['b'] = "a,b,c,d,e";$_POST['c'] = "男,女,女,男,男";$_POST['d'] = "25,26,27,26,26";$a = explode(',', $_POST['a']);$b = explode(',', $_POST['b']);$c = explode(',', $_POST['c']);$d = explode(',', $_POST['d']);foreach($a as $key=>$value){ $sql = "inser into tbl_name values('$value', '{$b[$key]}', '{$c[$key]}', '{$d[$key]}');"; //mysql_query($sql); echo $sql, PHP_EOL;