I have this code
function cranks($users = '', $all = '', $silent = false)
{
global $db, $user;
$sql_array = array(
'SELECT' => 'sum(u1.agi + u1.`int` + u1.str + u1.dex) as points1,
sum(u2.agi + u2.`int` + u2.str + u2.dex) as points2,
sum(u3.agi + u3.`int` + u3.str + u3.dex) as points3,
sum(u4.agi + u4.`int` + u4.str + u4.dex) as points4,
sum(s1.level) as skills1,
sum(s2.level) as skills2,
sum(s3.level) as skills3,
sum(s4.level) as skills4
',
'FROM' => array(USER_SQUAD_TABLE => 's'),
'LEFT_JOIN' => array(
array(
'FROM' => array(USER_CREATURES_TABLE => 'u1'),
'ON' => 'u1.id = s.cid1'
),
array(
'FROM' => array(USER_CREATURES_TABLE => 'u2'),
'ON' => 'u2.id = s.cid2'
),
array(
'FROM' => array(USER_CREATURES_TABLE => 'u3'),
'ON' => 'u3.id = s.cid3'
),
array(
'FROM' => array(USER_CREATURES_TABLE => 'u4'),
'ON' => 'u4.id = s.cid4'
),
array(
'FROM' => array(USER_SKILLS_TABLE => 's1'),
'ON' => 's1.cid = s.cid1'
),
array(
'FROM' => array(USER_SKILLS_TABLE => 's2'),
'ON' => 's2.cid = s.cid2'
),
array(
'FROM' => array(USER_SKILLS_TABLE => 's3'),
'ON' => 's3.cid = s.cid3'
),
array(
'FROM' => array(USER_SKILLS_TABLE => 's4'),
'ON' => 's4.cid = s.cid4'
),
array(
'FROM' => array(USERS_TABLE => 'm'),
'ON' => 's.uid = m.user_id'
)
),
'WHERE' => 'm.group_id != 6
AND m.user_type NOT IN (1,2)',
'ORDER_BY' => 'points1 DESC'
);
if($users != '')
{
$sql_array['WHERE'] .= ' AND s.uid = ' . $users;
}
elseif($all != '')
{
$sql_array['SELECT'] .= ', m.username, m.user_id';
$sql_array['GROUP_BY'] = ' m.user_id';
}
$sql = $db->sql_build_query('SELECT', $sql_array);
$result = $db->sql_query($sql);
//$userss = '';
while($row = $db->sql_fetchrow($result))
{
$total = $row['points1'] + $row['points2'] + $row['points3'] + $row['points4'] + $row['skills1'] + $row['skills2'] + $row['skills3'] + $row['skills4'] ;
if($all != '' && $total != 0)
{
$u[] = '<option value="'.$row['user_id'].'">'.$row['username'].' - Rating: '.$total.'</option>';
}
else
{
if($silent)
{
return $total;
}
else
{
return $total;
}
}
}
/*if($u != '')
{*/
$details = implode('<br/>', $u)
return $details;
//}
$db->sql_freeresult($result);
}
if i print u after its being added to all the details appear fine, but the return at the bottom shows nothing
any ideas why?