$query = $_SGLOBAL['db']->query("SELECT album.albumname, album.friend, space.username, space.name, space.namestatus, main.*
FROM ".tname('pic')." main
LEFT JOIN ".tname('album')." album ON album.albumid=main.albumid
LEFT JOIN ".tname('space')." space ON space.uid=main.uid
WHERE ".implode(' AND ', $wherearr)." // 这里多加个查询条件
GROUP BY main.uid ORDER BY main.{$order} $sc LIMIT 0,$shownum");