0
<input name="names[]" type="text"/><select><option value="male">male</option><option value="female">female</option></select>
<input name="names[]" type="text"/><select><option value="male">male</option><option value="female">female</option></select>
<input name="names[]" type="text"/><select><option value="male">male</option><option value="female">female</option></select>
if (!empty($_POST['names'])) {
foreach ($_POST['names'] AS $names) {
// add to the database
if (!empty($names)){
$rs=mysql_query("SELECT names FROM table WHERE names = '$names' LIMIT 1");
if(mysql_num_rows($rs) == 0) {
mysql_query("INSERT INTO table (names,gender) VALUES ('$names','$gender')");
}
}
}
}
這確實插入名稱,但我不知道如何我可以使性別爲每個單獨的名稱工作。如何用自己的類型插入多個數據?