我在参考space_friend.php //好友分组
$wheresql = '';
if($space['self']) {
$groups = getfriendgroup();
$group = !isset($_GET['group'])?'-1':intval($_GET['group']);
if($group > -1) {
$wheresql = "AND main.gid='$group'";
$theurl .= "&group=$group";
}
}
if($_GET['searchkey']) {
$wheresql = "AND main.fusername='$_GET[searchkey]'";
$theurl .= "&searchkey=$_GET[searchkey]";
}
if($space['friendnum']) {
if($wheresql) {
$count = $_SGLOBAL['db']->result($_SGLOBAL['db']->query("SELECT COUNT(*) FROM ".tname('friend')." main WHERE main.uid='$space[uid]' AND main.status='1' $wheresql"), 0);
} else {
$count = $space['friendnum'];
}
if($count) {
$query = $_SGLOBAL['db']->query("SELECT s.*, f.resideprovince, f.residecity, f.note, f.spacenote, f.sex, main.gid, main.num
FROM ".tname('friend')." main
LEFT JOIN ".tname('space')." s ON s.uid=main.fuid
LEFT JOIN ".tname('spacefield')." f ON f.uid=main.fuid
WHERE main.uid='$space[uid]' AND main.status='1' $wheresql
ORDER BY main.num DESC, main.dateline DESC
LIMIT $start,$perpage");
while ($value = $_SGLOBAL['db']->fetch_array($query)) {
realname_set($value['uid'], $value['username'], $value['name'], $value['namestatus']);
$value['p'] = rawurlencode($value['resideprovince']);
$value['c'] = rawurlencode($value['residecity']);
$value['group'] = $groups[$value['gid']];
$value['isfriend'] = 1;
$fuids[] = $value['uid'];
$value['note'] = getstr($value['note'], 28, 0, 0, 0, 0, -1);
$list[$value['uid']] = $value;
}
} |