<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<dates>
<?php
include_once("../config.php");

$con=mysql_connect($_SC['dbhost'],$_SC['dbuser'],$_SC['dbpw']);
mysql_select_db($_SC['dbname'],$con);
mysql_query("set names'utf8'");
$tablename1=$_SC['tablepre']."space";
$tablename2=$_SC['tablepre']."spacefield"; 
$tablename3=$_SC['tablepre']."major"; 

if(!empty($_REQUEST["username"])){$a1="and username like '%$_REQUEST[username]%' ";}else{$a1="";}//此处和一下必须用empty因为flex端为空时将传值为0
if(!empty($_REQUEST["sex"])){if($_REQUEST["sex"]==11){$a2="and $tablename2.sex=0 ";}elseif($_REQUEST["sex"]==1){$a2="and $tablename2.sex=1 ";}else{$a2="";}}
if(!empty($_REQUEST["group"])){$a3="and $tablename1.groupid=$_REQUEST[group] ";}else{$a3="";}
if(!empty($_REQUEST["major"])){$a4="and work_id=$_REQUEST[major] ";}else{$a4="";}//此处需要和产品的major表联动。

if(isset($_REQUEST['length'])){
	$a=$_REQUEST['length'];

$sql="select $tablename1.uid,username,sex,birthyear,note from $tablename1 left join $tablename2 on $tablename1.uid = $tablename2.uid left join $tablename3 on $tablename1.uid = $tablename3.u_id where 1=1 ".$a1.$a2.$a3.$a4."limit $a, 20";
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
$sex=$row['sex'];
if(empty($row['note'])){$note="想交个知心朋友...";}else{$note=$row['note'];}
$name=$row['username'];
$uid=$row['uid'];
if($uid<10){$tp=constant('UC_API')."/data/avatar/000/00/00/0".$uid."_avatar_middle.jpg";}else{$tp=constant('UC_API')."/data/avatar/000/00/00/".$uid."_avatar_middle.jpg";}
if(file($tp)==true){}else{$tp="img/ooxx.png";}
?>

<date2>
<uu><?=$uid?></uu>
<tp><?=$tp?></tp>
<name><?=$name?></name>
<sex><?=$sex?></sex>
<note><?=$note?></note>
</date2>

<?php
}
}else{
$sql="select $tablename1.uid,username,sex,birthyear,note from $tablename1 left join $tablename2 on $tablename1.uid = $tablename2.uid left join $tablename3 on $tablename1.uid = $tablename3.u_id where 1=1 ".$a1.$a2.$a3.$a4."limit 20";
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
$sex=$row['sex'];
if(empty($row['note'])){$note="想交个知心朋友...";}else{$note=$row['note'];}
$name=$row['username'];
$uid=$row['uid'];
if($uid<10){$tp=constant('UC_API')."/data/avatar/000/00/00/0".$uid."_avatar_middle.jpg";}else{$tp=constant('UC_API')."/data/avatar/000/00/00/".$uid."_avatar_middle.jpg";}
if(file($tp)==true){}else{$tp="img/ooxx.png";}
?>

<date>
<uu><?=$uid?></uu>
<tp><?=$tp?></tp>
<name><?=$name?></name>
<sex><?=$sex?></sex>
<note><?=$note?></note>
</date>

<?
}
}
?>
</dates>