foreach ($_POST as $key => $value){ $array[] = "add ".$key." varchar(220),"; } $string=rtrim(implode(" ",$array), ","); $sql="alter table fengxianxiangmu.weize_fengxian_qysb ".$string.""; echo $sql;