// 前置處理,加: elseif($_POST['type']=='編畢'){ mysql_query("update webMail set email='".$_POST['email']."' where eid=".$_POST['eid']); } elseif($_GET['type']=='editMailForm'){ echo editMailForm($_GET['eid']); } 函式加: function editMailForm($eid){ $result=mysql_query("select email from webMail where eid=".$eid); $row=mysql_fetch_array($result,MYSQL_ASSOC); $xx=new makeForm; $xx->elements[]=array('email:','text','email',$row['email']); $xx->elements[]=array('','hidden','eid',$eid); $xx->submitValue='編畢'; $xx->checkWhich='chkMailForm()'; return $xx->makeFormStr(); } 撈資料表改為: $result=mysql_query("select a.wid,b.eid,a.姓名,a.phone,b.email from web a left join webMail b on a.wid=b.wid where a.姓名!=''");//百分比代表萬用字元,只要裡面包含@都可以,left join是左側連結,where a.某欄=b.某欄 $colName=array('序','','wid','姓名','手機','±M','eid','Email'); nicetable函式改為: function nicetable($result,$colName){ $i=1; $str=""; $str.=""; $str.=""; foreach($colName as $colValue){ $str.=""; } $str.=""; $temp=array(); while($row=mysql_fetch_array($result,MYSQL_ASSOC)){ $temp[$row['wid']]['姓名']=$row['姓名']; $temp[$row['wid']]['phone']=$row['phone']; $temp[$row['wid']]['mail'][$row['eid']]=$row['email']; } foreach($temp as $k=>$v){ $rs=count($v['mail']);$j=0; foreach($v['mail'] as $kk=>$vv){ $str.=""; $str.=""; if($j==0){ $str.=""; $str.=""; $str.=""; $str.=""; } $str.=""; $str.=""; $str.=""; $j++; if($j==$rs){$j=0;} $str.=""; $i++; } } $str.="

增一人

".$colValue."
".$i." ".$k."".$temp[$k]['姓名']."".$temp[$k]['phone'].""; if($kk){$str.="  ";} $str.="".$kk."".$vv."
"; return $str; }