if(isset($_POST)){
$sql = 'INSERT INTO uu (uu_name,uu_phone) VALUES ';
foreach($_POST['uu_name'] as $k => $v){
$sql .= "('$v','".$_POST['uu_number'][$k]."'),";
}
$sql = substr($sql,0,-1);
//执行这条sql语句就可以了
echo $sql;
}
?>
// 循环插入数据
require 'db_connect.php';
if (isset($_POST['submit'])) {
foreach ($_POST['uu_name'] as $key => $vo) {
$uu_name = $vo;
$uu_phone = $_POST['uu_number'][$key];
$sql = "INSERT INTO table (uu_name, uu_phone) VALUES ('$uu_name', '$uu_phone')";
mysql_query($sql);
if (mysql_affected_rows()) {
echo '一条数据插入成功';
} else {
echo '一条数据插入失败';
}
}
exit();
}
exit('请求异常');
代码我不写。简单的方法就是把数据拼接成n个sql语句