index.htm定义了一个form,里面有两个变量agcode和agname传到后面的agent.php取出来的就是颠倒的比如agcode=333333333,agname=木井,到后面的agent.php中取出来的变量就是agname=33333333,agcode=木井愁死我了。代码如下:index.htm:<form name="agent" action="agent.php" method="post" target=_blank>
<table border='1' width=370>
<tr>代理人业务情况查询</tr>
<tr align=left>
<td />起始日期<input type='text' name='start' size=8 maxlength=8 value=''>
<td />终止日期<input type='text' name='end' size=8 maxlength=8 value=''>
</tr>
<tr align=left>
<td>名称<input type='text' name='agname' size=5></td>
<td>代码<input type='text' name='agcode' size=12></td>
</tr>
<tr align=left>
<td>
<select name=db>
<option value="cardb@hp3440_5">车</option>
<option value="insdb@hp3440_5">非车</option>
</select>
</td>
<td />机构代码<input type='text' name='com' size=6 maxlength=6 value='1303'>
</tr>
<tr>
<td align=center /> <input type='reset' value='重置'>
<td align=center /> <input type='submit' value='开始'>
</tr>
</table>
</form>
agent.php:<?
function create_agenttable()
{
$str="create temp table ag";
$str.="(comcode char(8),";
$str.=" code    char(12),";
$str.=" name    varchar(120,0))";
$str.="with no log";
return($str);
}
function select_code($agcode,$agname,$db)
{
if (!empty($agcode))
{
$str="insert into ag";
$str.=" select comcode,agentcode code,agentname name";
$str.=" from $db:prpdagent";
$str.=" where comcode matches '1303*'";
$str.=" and agentcode = \"".$agcode."\"";
$str.=" group by 1,2,3;";
$str.=" insert into ag";
$str.=" select comcode,usercode code,username name";
$str.=" from $db:prpduser";
$str.=" where comcode matches '1303*'";
$str.=" and usercode = \"".$agcode."\"";
$str.=" group by 1,2,3;";
}
else if (!empty($agname))
  {
echo "code=\$agcode+$agcode";
echo "name=\$agname+$agname";
$str="insert into ag";
$str.=" select comcode,agentcode code,agentname name";
$str.=" from $db:prpdagent";
$str.=" where comcode matches '1303*'";
$str.=" and agentname matches \"*".$agname."*\"";
$str.=" group by 1,2,3;";
$str.=" insert into ag";
$str.=" select comcode,usercode code,username name";
$str.=" from $db:prpduser";
$str.=" where comcode matches '1303*'";
$str.=" and username matches \"*".$agname."*\"";
$str.=" group by 1,2,3;";
}
else {die("你想累死我啊!请选一个吧!");};
return($str);
}
function select_result($com,$start,$end,$db,$db1)
{
$str="select a.comcode,a.policyno,a.sumpremium,a.startdate,a.enddate,";
$str.="a.insuredname,a.agentcode,b.agentname,c.registno,c.damagestartdate,";
$str.="c.endcasedate,c.sumclaim,c.sumpremium";
$str.=" from $db:prpcmain a left join $db1:prplclaim c on a.policyno=c.policyno,";
$str.=" $db:prpdagent b";
$str.=" where a.comcode matches '$com*'";
$str.=" and a.startdate between '$start' and '$end'";
$str.=" and a.agentcode=b.agentcode";
$str.=" and b.agentcode in (select code from ag)";
return($str);
}
function echo_ag()
{
$str="select * from ag where 1=1";
return($str);
}
$conn_id=ifx_connect("$db","tjtdata","tjtdata");
if($db="cardb@hp3440_5")
{
  $db1="claimdb@hp3440_5";
}
else if($db="insdb@hp3440_5")
{
  $db1="lpdb@hp3440_5";
}
ifx_query(create_agenttable(),$conn_id);
ifx_query(select_code($agname,$agcode,$db),$conn_id);
$rs_id1=ifx_query(echo_ag(),$conn_id);
ifx_htmltbl_result($rs_id1,"border=\"1\"");
$rs_id=ifx_query(select_result($com,$start,$end,$db,$db1),$conn_id);
ifx_htmltbl_result($rs_id,"border=\"1\"");
?>