$s="select * from ".$DBhrm."._cardinfo where state!=1 and sid=".$row['id']; $r=mysql_query($s); $sr=mysql_fetch_array($r); $cardno=$sr['cardno'];
$s1="select * from ".$DBhrm."._staffjobinfo where state!=1 and sid=".$row['id'];//入職 $r1=mysql_query($s1); $sr1=mysql_fetch_array($r1);
$s2="select * from ".$DBhrm."._department where state!=1 and id=".$sr1['did']; //部門 $r2=mysql_query($s2); $sr2=mysql_fetch_array($r2); $departmentname=$sr2['departmentname'];
$s3="select * from ".$DBhrm."._staffgroupinfo where state!=1 and id=".$sr1['gid']; //組別 $r3=mysql_query($s3); $sr3=mysql_fetch_array($r3); $groupname=$sr3['groupname'];
$s="select * from ".$DBhrm."._cardinfo where state!=1 and sid=".$row['id']; $r=mysql_query($s); $sr=mysql_fetch_array($r); $cardno=$sr['cardno'];
$s1="select * from ".$DBhrm."._staffjobinfo where state!=1 and sid=".$row['id'];//入職 $r1=mysql_query($s1); $sr1=mysql_fetch_array($r1);
$s2="select * from ".$DBhrm."._department where state!=1 and id=".$sr1['did']; //部門 $r2=mysql_query($s2); $sr2=mysql_fetch_array($r2); $departmentname=$sr2['departmentname'];
$s3="select * from ".$DBhrm."._staffgroupinfo where state!=1 and id=".$sr1['gid']; //組別 $r3=mysql_query($s3); $sr3=mysql_fetch_array($r3); $groupname=$sr3['groupname'];
$s="select * from ".$DBhrm."._cardinfo where state!=1 and sid=".$row['id']; $r=mysql_query($s); $sr=mysql_fetch_array($r); $cardno=$sr['cardno'];
$s1="select * from ".$DBhrm."._staffjobinfo where state!=1 and sid=".$row['id'];//入職 $r1=mysql_query($s1); $sr1=mysql_fetch_array($r1);
$s2="select * from ".$DBhrm."._department where state!=1 and id=".$sr1['did']; //部門 $r2=mysql_query($s2); $sr2=mysql_fetch_array($r2); $departmentname=$sr2['departmentname'];
$s3="select * from ".$DBhrm."._staffgroupinfo where state!=1 and id=".$sr1['gid']; //組別 $r3=mysql_query($s3); $sr3=mysql_fetch_array($r3); $groupname=$sr3['groupname'];
$s4="select * from ".$DBhrm."._jobnameinfo where state!=1 and id=".$sr1['jid']; //職務 $r4=mysql_query($s4); $sr4=mysql_fetch_array($r4); $jobname=$sr4['jobname']; $s5="select * from ".$DBhrm."._roominfo where state!=1 and id=".$row['rid'];//宿舍 $r5=mysql_query($s5); $sr5=mysql_fetch_array($r5); $roomno=$sr5['roomno'];omg~ php业务层怎么能这么写呢。。你难道不知道sql语句可以多表联合查询么?你那么多业务逻辑,其实就是一条sql语句 left join ,right join ,inner join...。
==============================================================
你是怎么写的?7000条记录而已,循环起来不会慢。
<TABLE width="810" border=0 align="center" cellPadding=0 cellSpacing=0 class="table" frame="box" id="table1">
<TR bgcolor="#cccccc" align="center">
<td width="22" height="21"> </td>
<td width="48" >工號</td>
<td width="56" >姓名</td>
<td width="37" >性別</td>
<td width="87" >部門</td>
<td width="74" >組別</td>
<td width="67" >職務</td>
<td width="85" >入廠日期</td>
<td width="47" >卡號</td>
<td width="62" >入住宿舍</td>
<td width="40" >籍貫</td>
<td width="76" >出生日期</td>
<td width="50" >民族</td>
<td width="57" >學歷</td>
</TR>
<?
$sql="select * from ".$DBhrm."._staffinfo where state!=1 order by staffid desc ";
$rs=mysql_query($sql);
foreach($rs as $value)
{
echo $value[0].$value[1].$value[2].$value[3]."888999<br>";
}
while($row=mysql_fetch_array($rs))
{
$sid=$row['id'];
$staffid=$row['staffid'];
$staffname=$row['staffname'];
$idcardno=$row['idcardno'];
$gender=$row['gender'];
$province=$row['province'];
$birthday=$row['birthday'];
$nation=$row['nation'];
$provinceaddress=$row['provinceaddress'];
$joindate=$row['joindate'];
$introducer=$row['introducer'];
$s="select * from ".$DBhrm."._cardinfo where state!=1 and sid=".$row['id'];
$r=mysql_query($s);
$sr=mysql_fetch_array($r);
$cardno=$sr['cardno'];
$s1="select * from ".$DBhrm."._staffjobinfo where state!=1 and sid=".$row['id'];//入職
$r1=mysql_query($s1);
$sr1=mysql_fetch_array($r1);
$s2="select * from ".$DBhrm."._department where state!=1 and id=".$sr1['did']; //部門
$r2=mysql_query($s2);
$sr2=mysql_fetch_array($r2);
$departmentname=$sr2['departmentname'];
$s3="select * from ".$DBhrm."._staffgroupinfo where state!=1 and id=".$sr1['gid']; //組別
$r3=mysql_query($s3);
$sr3=mysql_fetch_array($r3);
$groupname=$sr3['groupname'];
$s4="select * from ".$DBhrm."._jobnameinfo where state!=1 and id=".$sr1['jid']; //職務
$r4=mysql_query($s4);
$sr4=mysql_fetch_array($r4);
$jobname=$sr4['jobname'];
$s5="select * from ".$DBhrm."._roominfo where state!=1 and id=".$row['rid'];//宿舍
$r5=mysql_query($s5);
$sr5=mysql_fetch_array($r5);
$roomno=$sr5['roomno'];
?>
<TR bgcolor="#E8E8E8" onMouseOver=this.style.backgroundColor='#cccccc' onMouseOut=this.style.backgroundColor='' align="center" >
<TD>
<input type="checkbox" name="select[]" value="<? echo $sid;?>" /></TD>
<TD ><? echo $staffid;?> </TD>
<TD ><? echo $staffname;?> </TD>
<TD ><? echo $gender;?> </TD>
<TD ><? echo $departmentname;?> </TD>
<TD ><? echo $groupname;?> </TD>
<TD ><? echo $jobname;?> </TD>
<TD ><? echo $joindate;?> </TD>
<TD ><? echo $cardno;?> </TD>
<TD >]<? echo $roomno;?> </TD>
<TD ><? echo $province;?> </TD>
<TD ><? echo $birthday;?> </TD>
<TD ><? echo $nation;?> </TD>
<TD ></TD>
</TR> <?
}?></TABLE>
<TR bgcolor="#cccccc" align="center">
<td width="22" height="21"> </td>
<td width="48" onClick="sortTable('table1','str',this,1,0)" sortType="asc">
<a href="javascript:void(0);"><font color="#000000">工號</font></a></td>
<td width="56" onClick="sortTable('table1','str',this,1,0)" sortType="asc">
<a href="javascript:void(0);"><font color="#000000">姓名</font></a></td>
<td width="37" onClick="sortTable('table1','str',this,1,0)" sortType="asc">
<a href="javascript:void(0);"><font color="#000000">性別</font></a></td>
<td width="87" onClick="sortTable('table1','str',this,1,0)" sortType="asc">
<a href="javascript:void(0);"><font color="#000000">部門</font></a></td>
<td width="74" onClick="sortTable('table1','str',this,1,0)" sortType="asc">
<a href="javascript:void(0);"><font color="#000000">組別</font></a></td>
<td width="67" onClick="sortTable('table1','str',this,1,0)" sortType="asc">
<a href="javascript:void(0);"><font color="#000000">職務</font></a></td>
<td width="85" onClick="sortTable('table1','str',this,1,0)" sortType="asc">
<a href="javascript:void(0);"><font color="#000000">入廠日期</font></a></td>
<td width="47" onClick="sortTable('table1','str',this,1,0)" sortType="asc">
<a href="javascript:void(0);"><font color="#000000">卡號</font></a></td>
<td width="62" onClick="sortTable('table1','str',this,1,0)" sortType="asc">
<a href="javascript:void(0);"><font color="#000000">入住宿舍</font></a></td>
<td width="40" onClick="sortTable('table1','str',this,1,0)" sortType="asc">
<a href="javascript:void(0);"><font color="#000000">籍貫</font></a></td>
<td width="76" onClick="sortTable('table1','str',this,1,0)" sortType="asc">
<a href="javascript:void(0);"><font color="#000000">出生日期</font></a></td>
<td width="50" onClick="sortTable('table1','str',this,1,0)" sortType="asc">
<a href="javascript:void(0);"><font color="#000000">民族</font></a></td>
<td width="57" onClick="sortTable('table1','str',this,1,0)" sortType="asc">
<a href="javascript:void(0);"><font color="#000000">學歷</font></a></td>
</TR>
<?
$sql="select * from ".$DBhrm."._staffinfo where state!=1 order by staffid desc ";
$rs=mysql_query($sql);
while($row=mysql_fetch_array($rs))
{
$sid=$row['id'];
$staffid=$row['staffid'];
$staffname=$row['staffname'];
$idcardno=$row['idcardno'];
$gender=$row['gender'];
$province=$row['province'];
$birthday=$row['birthday'];
$nation=$row['nation'];
$provinceaddress=$row['provinceaddress'];
$joindate=$row['joindate'];
$introducer=$row['introducer'];
$s="select * from ".$DBhrm."._cardinfo where state!=1 and sid=".$row['id'];
$r=mysql_query($s);
$sr=mysql_fetch_array($r);
$cardno=$sr['cardno'];
$s1="select * from ".$DBhrm."._staffjobinfo where state!=1 and sid=".$row['id'];//入職
$r1=mysql_query($s1);
$sr1=mysql_fetch_array($r1);
$s2="select * from ".$DBhrm."._department where state!=1 and id=".$sr1['did']; //部門
$r2=mysql_query($s2);
$sr2=mysql_fetch_array($r2);
$departmentname=$sr2['departmentname'];
$s3="select * from ".$DBhrm."._staffgroupinfo where state!=1 and id=".$sr1['gid']; //組別
$r3=mysql_query($s3);
$sr3=mysql_fetch_array($r3);
$groupname=$sr3['groupname'];
$s4="select * from ".$DBhrm."._jobnameinfo where state!=1 and id=".$sr1['jid']; //職務
$r4=mysql_query($s4);
$sr4=mysql_fetch_array($r4);
$jobname=$sr4['jobname'];
$s5="select * from ".$DBhrm."._roominfo where state!=1 and id=".$row['rid'];//宿舍
$r5=mysql_query($s5);
$sr5=mysql_fetch_array($r5);
$roomno=$sr5['roomno'];
/*
echo "<TR bgcolor='#E8E8E8' onMouseOver=this.style.backgroundColor='#cccccc' onMouseOut=this.style.backgroundColor='' align='center' >
<TD>
<input type='checkbox' name='select[]' value='".$sid."' /></TD>
<TD>".$staffid."</TD>
<TD >".$staffname."</TD>
<TD >".$gender."</TD>
<TD >".$departmentname."</TD>
<TD >".$groupname."</TD>
<TD >".$jobname."</TD>
<TD >".$joindate."</TD>
<TD >".$cardno."</TD>
<TD >".$roomno."</TD>
<TD >".$province."</TD>
<TD >".$birthday."</TD>
<TD >".$nation."</TD>
<TD ></TD>
</TR>";*/
?>
<TR bgcolor="#E8E8E8" onMouseOver=this.style.backgroundColor='#cccccc' onMouseOut=this.style.backgroundColor='' align="center" >
<TD>
<input type="checkbox" name="select[]" value="<? echo $sid;?>" /></TD>
<TD><? echo $staffid;?></TD>
<TD ><? echo $staffname;?></TD>
<TD ><? echo $gender;?></TD>
<TD ><? echo $departmentname;?></TD>
<TD ><? echo $groupname;?></TD>
<TD ><? echo $jobname;?></TD>
<TD ><? echo $joindate;?></TD>
<TD ><? echo $cardno;?></TD>
<TD ><? echo $roomno;?></TD>
<TD ><? echo $province;?></TD>
<TD ><? echo $birthday;?></TD>
<TD ><? echo $nation;?></TD>
<TD ></TD>
</TR>
<?
}
?></TABLE>上面代码太乱,重发一个!
$r=mysql_query($s);
$sr=mysql_fetch_array($r);
$cardno=$sr['cardno'];
$s1="select * from ".$DBhrm."._staffjobinfo where state!=1 and sid=".$row['id'];//入職
$r1=mysql_query($s1);
$sr1=mysql_fetch_array($r1);
$s2="select * from ".$DBhrm."._department where state!=1 and id=".$sr1['did']; //部門
$r2=mysql_query($s2);
$sr2=mysql_fetch_array($r2);
$departmentname=$sr2['departmentname'];
$s3="select * from ".$DBhrm."._staffgroupinfo where state!=1 and id=".$sr1['gid']; //組別
$r3=mysql_query($s3);
$sr3=mysql_fetch_array($r3);
$groupname=$sr3['groupname'];
$s4="select * from ".$DBhrm."._jobnameinfo where state!=1 and id=".$sr1['jid']; //職務
$r4=mysql_query($s4);
$sr4=mysql_fetch_array($r4);
$jobname=$sr4['jobname'];
$s5="select * from ".$DBhrm."._roominfo where state!=1 and id=".$row['rid'];//宿舍
$r5=mysql_query($s5);
$sr5=mysql_fetch_array($r5);
$roomno=$sr5['roomno'];omg~
php业务层怎么能这么写呢。。你难道不知道sql语句可以多表联合查询么?你那么多业务逻辑,其实就是一条sql语句
left join ,right join ,inner join...。