日期:2014-05-17 浏览次数:20455 次
<tr>
<td>1</td>
<td><input type="text" name="name[]" value="许亮"></td>
<td><input type="text" name="age[]" value="25"></td>
<td><input type="text" name="position[]" value="SAP开发工程师"></td>
</tr>
<tr>
<td>2</td>
<td><input type="text" name="name[]" value="周未红"></td>
<td><input type="text" name="age[]" value="22"></td>
<td><input type="text" name="position[]" value="招聘主管"></td>
</tr>
<tr>
<td>3</td>
<td><input type="text" name="name[]" value="胡睿妮"></td>
<td><input type="text" name="age[]" value="24"></td>
<td><input type="text" name="position[]" value="银行职员"></td>
</tr>
<tr>
<td>4</td>
<td><input type="text" name="name[]" value="张凯"></td>
<td><input type="text" name="age[]" value="35"></td>
<td><input type="text" name="position[]" value="经理"></td>
</tr>
<?php
$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 "<pre>";
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());
&nb