TinyPortal

Development => Block Codes => Topic started by: brianjw on February 25, 2007, 07:54:26 PM

Title: Help with getting this code to display people in a certain order.
Post by: brianjw on February 25, 2007, 07:54:26 PM
I am using the teampage the code...

global $txt, $scripturl, $user_info;
global $context, $modSettings, $ID_MEMBER;
global $board_info, $settings, $db_prefix;

/////////////////////////////////////////////////////////////////Ã,  Enter the desired groups
$groups_list = array(1,2,3,10,9,11,12);
/////////////////////////////////////////////////////////////////
$groups_query1 = 'mem.ID_GROUP IN (' . implode(', ', $groups_list) . ')';
$groups_query2 = '';
// $groups_query2 = ' OR FIND_IN_SET(' . implode(', mem.additionalGroups) OR FIND_IN_SET(', $groups_list) . ', mem.additionalGroups)';


Ã,  Ã,  Ã,   echo '<table align="center" width="95%" cellpadding="0" cellspacing="0"><tr>
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  <td style="border-bottom: 2px solid #C7A276; padding-bottom: 4px; "><h2>Meet the Team</h2>
<span class="smalltext">The people you will run into while visiting brianjwilson.com.</span><br /><br />
</td></tr></table>';


$loaded_ids = array();
Ã,  Ã,  $user_profile=array();
Ã,  Ã,  $memberContext=array();
Ã,  Ã,  $profile=array();
Ã,  Ã,  $context['TPortal']['team']=array();

// Load the member's data.
$request = db_query("
SELECT IFNULL(lo.logTime, 0) AS isOnline, IFNULL(a.ID_ATTACH, 0) AS ID_ATTACH, a.filename, a.attachmentType,
mem.personalText, mem.avatar, mem.ID_MEMBER, mem.memberName, mem.realName , mem.lastLogin, mem.websiteTitle,
mem.websiteUrl, mem.location, mem.posts, them.value AS teamtext, g.groupName
FROM ({$db_prefix}members AS mem, {$db_prefix}membergroups AS g)
LEFT JOIN {$db_prefix}log_online AS lo ON (lo.ID_MEMBER = mem.ID_MEMBER)
LEFT JOIN {$db_prefix}attachments AS a ON (a.ID_MEMBER = mem.ID_MEMBER)
LEFT JOIN {$db_prefix}themes AS them ON (mem.ID_MEMBER = them.ID_MEMBER AND them.variable = 'teamtext' AND them.ID_THEME=1)
WHERE mem.ID_GROUP = g.ID_GROUP
AND ($groups_query1 $groups_query2)
ORDER BY mem.realName ASC", __FILE__, __LINE__);
$new_loaded_ids = array();
while ($row = mysql_fetch_assoc($request))
{

$avatar_width = '';
$avatar_height = '';

$context['TPortal']['team'][] = array(
'username' => $row['memberName'],
'name' => $row['realName'],
'groupname' => $row['groupName'],
'posts' => $row['posts'],
'location' => $row['location'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['realName'] . '">' . $row['realName'] . '</a>',
'blurb' => $row['personalText'],
'avatar' => array(
'name' => $row['avatar'],
'image' => $row['avatar'] == '' ? ($row['ID_ATTACH'] > 0 ? '<imgÃ,  src="' . (empty($row['attachmentType']) ? $scripturl . '?action=dlattach;attach=' . $row['ID_ATTACH'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" class="avatar2" border="0" />' : '') : (stristr($row['avatar'], 'http://') ? '<img src="' . $row['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" class="avatar2" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row['avatar']) . '" alt="" class="avatar2" border="0" />'),
'href' => $row['avatar'] == '' ? ($row['ID_ATTACH'] > 0 ? (empty($row['attachmentType']) ? $scripturl . '?action=dlattach;attach=' . $row['ID_ATTACH'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),
'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar'])
),
'last_login' => empty($row['lastLogin']) ? $txt['never'] : timeformat($row['lastLogin']),
'last_login_timestamp' => empty($row['lastLogin']) ? 0 : forum_time(0, $row['lastLogin']),
'website' => array(
'title' => $row['websiteTitle'],
'url' => $row['websiteUrl']),
'online' => array(
'is_online' => $row['isOnline'],
'text' => &$txt[$row['isOnline'] ? 'online2' : 'online3'],
'image_href' => $settings['images_url'] . '/' . ($row['isOnline'] ? 'useron' : 'useroff') . '.gif',
),
'teamtext' => $row['teamtext'],
);


}
mysql_free_result($request);

echo '<table align="center" width="95%" cellpadding="5" cellspacing="5"><tr>';

Ã,  Ã,  $newrow=0;
foreach($context['TPortal']['team'] as $team)
Ã,  Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  echo '
<td valign="top">'.$team['avatar']['image'].'</td>
<td valign="top" width="50%" class="middletext" style="padding: 5px;">
<h2 style="margin-top: 0; margin-bottom: 6px;">'.$team['link'].'</h2>
<b>'.$team['groupname'].'</b><br />
<b>Last seen</b>: '.$team['last_login'].'<br />
<b>Posts</b>: '.$team['posts'].'<br />
' , !empty($team['location']) ? '<b>Location</b>: '.$team['location'].'<br />' : '' , '
' , !empty($team['website']['title']) ? '<b>Website</b>: <a href="'.$team['website']['url'].'" target="_blank">'.$team['website']['title'].'</a><br />' : '' , '
' ,Ã,  $team['online']['is_online'] ? '<img src="'.$team['online']['image_href'].'" alt="" /> '.$team['online']['text'].'<br />' : $team['online']['text'].'<br />' , '

' , !empty($team['blurb']) ? '<i>- '.$team['blurb'].'</i><br />' : '' , '

' ,Ã,  !empty($team['teamtext']) ? $team['teamtext'].'<br />' : '' , '

Ã,  Ã,  </div></td>';
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  $newrow++;
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  if($newrow>1){
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,   $newrow=0;
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,   echo '</tr><tr><td colspan="4"><br /><br /> </td></tr><tr>';
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã,  }
echo '</tr></table>';


How do I make it display the staff by greatest to least on posts...?
NOW: http://brianjwilson.com/index.php?action=team

Thanks
Brianjw
Title: Re: Help with getting this code to display people in a certain order.
Post by: JPDeni on February 25, 2007, 07:59:39 PM
Change


ORDER BY mem.realName ASC


to


ORDER BY mem.posts DESC
Title: Re: Help with getting this code to display people in a certain order.
Post by: brianjw on February 25, 2007, 08:22:11 PM
Thanks :)

FIXED it :D
Title: Re: Help with getting this code to display people in a certain order.
Post by: G6Cad on February 25, 2007, 09:51:34 PM
And PLEASE, start to learn where to place your posts sometime, it's starting to get really annoying to move your posts made to where they should have been posted in the first place.
You have over 800 posts made in here now so you should know it by now.
Ans Im NOT joking this time Brian.  From now on i will just delete the posts you make if they are not made in the correct place
Title: Re: Help with getting this code to display people in a certain order.
Post by: brianjw on February 25, 2007, 09:57:16 PM
Ok, today I admit I was a little sloppy where i place my stuff because I noticed you moved the Web hosting one and this one. I will fix this in my head so it won't happen again ;)
I just need to get used to the boards other than Chitchat and TP Support and Development because those are the ones I know :D

Brianjw