<form action="" method="post">
<input type=text name=name><input type=text name=sex><br/>
<input type=text name=name><input type=text name=sex><br/>
<input type="Submit" value=" 提交" size="50"/>
</form>
如果是10条,20条,或者更多呢,假设我的MYSQL表名是test,PHP部分如何写呢?本人是PHP新手,希望你回答的时候越详细越好,先给15分吧,回答好的我加分,谢谢了···
é¦å
form表å
<form action="" method="post">
<input type=text name=name[]><input type=text name=sex[]><br/>
<input type=text name=name[]><input type=text name=sex[]><br/>
<input type="Submit" value=" æ交" size="50"/>
</form>
ç¶åphp页é¢ï¼
<?php
mysql_connect("localhost","root","password");
mysql_select_db("databasename");
mysql_query("set names 'utf8'");
$name=$_POST['name'];
$sex=$_POST['sex'];
foreach($name as $key=>$value){
mysql_query("insert into test(name,sex) values('$value','".$sex[$key]."')");
}
?>
æé®é¢çè¯ï¼è¿½å é®é¢
<form action="" method="post">
<input type=text name=name[]><input type=text name=sex[]><br/>
<input type=text name=name[]><input type=text name=sex[]><br/>
<input type="Submit" value=" æ交" size="50"/>
</form>
ç¶åphp页é¢ï¼
<?php
mysql_connect("localhost","root","password");
mysql_select_db("databasename");
mysql_query("set names 'utf8'");
$name=$_POST['name'];
$sex=$_POST['sex'];
foreach($name as $key=>$value){
mysql_query("insert into test(name,sex) values('$value','".$sex[$key]."')");
}
?>
æé®é¢çè¯ï¼è¿½å é®é¢
温馨提示:答案为网友推荐,仅供参考