$db = mysql_connect("localhost","root","");
mysql_select_db ("mydata");
$res = mysql_query ("select xh,xm from lqdyk where ksh='$ksh'");
$resArr = mysql_fetch_array($res);
$xh = $resArr['xh'];
$xm = $resArr['xm'];
$result = mysql_query ("insert into maildata (ksh, xh, xm, yhm, mm)
VALUES ('$ksh', '$xh', '$xm', '$yhm','$mm')");