时间:2021-07-01 10:21:17 帮助过:15人阅读
1
2
3
4
$db_name="test";
$table_name="co_arr";
$connection= @mysql_connect("localhost","root","smtroot") or die(mysql_error());
$db= @mysql_select_db($db_name,$connection) or die (mysql_error());
mysql_query("SET NAMES GBK");
echo "";
print_r($_POST["name"]);
print_r($_POST["age"]);
print_r($_POST["position"]);
//计算传递过来的文本框的行数
$arr_Length = count($_POST["name"]);
$name_arr = $_POST["name"];
$age_arr = $_POST["age"];
$position_arr = $_POST["position"];
/*循环插入语句*/
for($i=0;$i<$arr_Length;$i++){
$sql = "insert into co_arr(name,age,position)";
$sql .= "values('$name_arr[$i]','$age_arr[$i]','$position_arr[$i]')";
$query = @mysql_query($sql,$connection) or die(mysql_error());
//echo $_POST["name"][$i]."
";
}
?>