我从几个下拉列表输入到一个字段表的答案中找到了这段代码。它看起来真的像是我可以在我当前的项目中使用的东西。当前的项目是关于用两个下拉框填充一个表(它们自己用表填充)。但是,我不明白我需要做哪些个人更改才能使其正常工作。属性?:属性?有人能理解吗?
$levels = $_POST['level1'][0].",".$_POST['level1'][1];
//Now you have a string called $levels
// Which contains a comma seperated list, to insert into db / one field
//Insert into your table...change your table and field names to real values...
$sql = "INSERT INTO yourTable (attributes) VALUES (:attributes)";
$q = $db->prepare($sql);
$q->execute(array(':attributes'=>$levels));
?>