//查询部门 $sql_depart="SELECT * FROM depart WHERE gid>0 AND gid $query_depart=$db->query($sql_depart); while($d=$db->fetch_array($query_depart)){ ?>
//查询人员
$sql_user="SELECT * FROM members WHERE flag $query_user=$db->query($sql_user); while($u=$db->fetch_array($query_user)){ ?>
//查询所有日志 $sql="SELECT c1.*,c2.* FROM log c1 LEFT JOIN log_time c2 ON (c1.time_id=c2.tid) WHERE c2.year='".$year."' AND c1.userid='".$u['uid']."' AND c2.end_date $query=$db->query($sql); while($row=$db->fetch_array($query)){
SELECT d.*,m.*,l.* FROM depart d left join members m on m.flagleft join (SELECT c1.*,c2.* FROM log c1 LEFT JOIN log_time c2 ON (c1.time_id=c2.tid) WHERE c2.year='".$year."' AND c2.end_dateWHERE d.gid>0 AND d.gid