TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 350
  • Total: 350

Roster Page

Started by londonhogfan, May 31, 2006, 06:56:37 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

londonhogfan

wow. that worked.

only things I notice that would cause a problem.  The "game alias" has their rank.  I manually added those using the code.  So the code used now has.

-RoTa- Gen| '[their name]'

anyway to change the tag for each one to show their correct rank.  I could create a new field using the custom profiles mod to make a new field (only editiable by me) to put their rank in there.  only other thing I see is the images don't show up.

-Jacob

JPDeni

#101
That's whole lot better!  ;D Even worse than forgetting a semi-colon. Oh, well. Fixed now.  :)

QuoteSo the code used now has.

-RoTa- Gen| '[their name]'

I see. It's not a problem. We can just add that in. No need to add a new field, unless you're going to use it elsewhere.

At the beginning, you can set up the abbreviations, like this:


$abbrev = array(
  'General' => 'Gen',
  'Brigadier General' => 'BGen',
  'Colonel' => 'Col',
  'Lieutenant Colonel' => 'LtCol',
  'Captain' => 'Cap',
  '1st Lieutenant' => '1stLt',
  'Sergeant Major' => 'SgtMaj',
  'First Sergeant' => '1stSgt',
  'Master Sergeant' => 'MSgt',
  'Staff Sergeant' => 'SSgt',
  'Sergeant' => 'Sgt',
  'Corporal' => 'Cpl',
  'Lance Corporal' => 'LCpl',
  'Private First Class' => 'PFC',
  'Private'  => 'Pvt'
);


Then, where you have

$row2['ID_MEMBER'] . '">-RoTa- Gen|<b><font color="' .[/quote]

use

[code]$row2['ID_MEMBER'] . '">-RoTa- ' . $abbrev[$rank] . '|<b><font color="' .


As for the images....

Try changing

    'stars' => empty($row['stars']) ? '' : substr($row['stars'],2)
to
    'stars' => empty($row['stars']) ? '' : $row['stars']

That was really a guess as to how things are set up and I still don't know if it's right. We may need to create another array instead of pulling them from the database.[/code]

londonhogfan

#102
this is what I have right now...


global $db_prefix, $scripturl, $txt, $settings, $options;


// These must be in the order you wish them to print out on your roster.
// VERY IMPORTANT!!!! -- they must be exactly the same as the group names in the database, including
// capitalization and spaces. (I notice that "Major" is missing.)
$abbrev = array(
$rankorder = array(
  'General' => 'Gen',
  'Brigadier General' => 'BGen',
  'Colonel' => 'Col',
  'Lieutenant Colonel' => 'LtCol',
  'Captain' => 'Cap',
  '1st Lieutenant' => '1stLt',
  'Sergeant Major' => 'SgtMaj',
  'First Sergeant' => '1stSgt',
  'Master Sergeant' => 'MSgt',
  'Staff Sergeant' => 'SSgt',
  'Sergeant' => 'Sgt',
  'Corporal' => 'Cpl',
  'Lance Corporal' => 'LCpl',
  'Private First Class' => 'PFC',
  'Private'  => 'Pvt'
);

$groups = '';
//Does all the real work here for showing groups.
$query = db_query("SELECT ID_GROUP, groupName, onlineColor, stars
  FROM {$db_prefix}membergroups", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($query))
{
  $groups[$row['groupName']]  = array(
    'id' => $row['ID_GROUP'],
    'color' => empty($row['onlineColor']) ? '' : $row['onlineColor'],
'stars' => empty($row['stars']) ? '' : $row['stars'],
  );
}
mysql_free_result($query);

foreach ($rankorder as $rank)
{
//Now get all the users
  $query2 = db_query("
    SELECT ID_GROUP, ID_MEMBER, realName, avatar, usertitle,
           emailAddress, hideEmail, lastLogin, location, personalText,
           totalTimeLoggedIn, dateRegistered, ICQ, AIM, YIM, MSN, cs_stats,
           css_stats, hideEmail, emailAddress
    FROM {$db_prefix}members
    WHERE ID_GROUP = '" . $groups[$rank]['id'] . "' ", __FILE__, __LINE__);

  if(db_affected_rows() != 0)
  {
    echo '<table border="0" cellspacing="1" cellpadding="5" align="center" class="bordercolor">
      <tr><td colspan="7" class="catbg"><font size="4" face="verdana"><b>' . $rank . '</b></font></td></tr>
      <tr><td rowspan="70" width="85" class="profilebg" valign="top">
        <center><img src="' . $settings['images_url'] . '/medium/' . $groups[$rank]['stars'] . '"></center></td>';
      echo '<td class="catinfo" width="25"></td>';
      echo '<td class="catinfo" width="245"><b>GAMING ALIAS</b></td>';
      echo '<td class="catinfo" width="130"><b>NAME</b></td>';
      echo '<td class="catinfo" width="170"><b>LAST ONLINE</b></td>';
      echo '<td class="catinfo" width="100"><b>PSYCHOSTATS</b></td>';
      echo '<td class="catinfo" width="175"><b>CONTACT</b></td></tr><tr>';
      while ($row2 = mysql_fetch_assoc($query2))
      {
        echo '<td class="windowbg2 height="40"><img src="http://www.the-rota.com/Themes/default/images/flags/' . $row2['location'] . '.png" alt="' . $row2['location'] . '"></td>';
        echo '<td class="windowbg" height="40"><a href="' . $scripturl . '?action=profile;u=' . [code]$row2['ID_MEMBER'] . '">-RoTa- ' . $abbrev[$rank] . '|<b><font color="' . $groups[$rank]['color'] . '" size="3" face="verdana">' . $row2['realName'] . '</b></font></font></a><br><font size="1"> ' . $row2['personalText'] . '</font></a></td><td class="windowbg2">' . $row2['usertitle'] . '</td>';
        echo '<td class="windowbg">' . timeformat($row2['lastLogin']) . '</td>';
        echo '<td class="windowbg2" align="center">';
        if($row2['cs_stats'] != '')
          echo '<a href="' . $row2['cs_stats'] . '" target="_blank"><img src="' . $settings['images_url'] . '/cs_stats.gif" alt="CS 1.6 Stats" border="0" /></a> ';
        if($row2['css_stats'] != '')
          echo '<a href="' . $row2['css_stats'] . '" target="_blank"><img src="' . $settings['images_url'] . '/css_stats.gif" alt="CS:Source Stats" border="0" /></a> ';
        echo '</td><td class="windowbg">';

//Send email row
        if($row2['hideEmail'] == 0)
          echo '<a href="mailto:', $row2['emailAddress'], '"><img src="' . $settings['images_url'] . '/email_sm.gif" alt="email" /></a> ';

        if($row2['ICQ'] != '')
          echo '<a href="http://www.icq.com/whitepages/about_me.php?uin=' . $row2['ICQ'] . '" target="_blank"><img src="http://status.icq.com/online.gif?img=5&icq=' . $row2['ICQ'] . '" alt="' . $row2['ICQ'] . '" width="18" height="18" border="0" /></a> ';
        if($row2['AIM'] != '')
          echo '<a href="aim:goim?screenname=' . urlencode(strtr($row2['AIM'], array(' ' => '%20'))) . '&message=' . $txt['aim_default_message'] . '"><img src="' . $settings['images_url'] . '/aim.gif" alt="' . $row2['AIM'] . '" border="0" /></a> ';
        if($row2['YIM'] != '')
          echo '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($row2['YIM']) . '"><img src="http://opi.yahoo.com/online?u=' . urlencode($row2['YIM']) . '&m=g&t=0" alt="' . $row2['YIM'] . '" border="0" /></a> ';
        if($row2['MSN'] != '')
          echo '<a href="http://members.msn.com/' . $row2['MSN'] . '" target="_blank"><img src="' . $settings['images_url'] . '/msntalk.gif" alt="' . $row2['MSN'] . '" border="0" /></a> ';

//Send PM row
        echo '<a href="' . $scripturl . '?action=pm;sa=send;u=' . $row2['ID_MEMBER'] . '"><img src="' . $settings['images_url'] . '/im_on.gif" alt="email" /></a></a>';
        echo '</td>';
        echo '</tr>';
      }
    echo '</table><br>';
  }
}


I will re-try the edits after work (couple hours) to see if I just entered them wrong.

you seem to know what your doing and there is something I have been wanting to add to this for a long time, but don't have the know how...

Our clan is setup by military (marine) ranks.  We have near 60 members now and we are split into 3 teams.  [MFR], [SRB], and [STA]  I have not found a way to put these on the roster so far. 

Our game names are actually -RoTa- BGen|Achilles [SRB] but I can't get the team tag on there.  The only ones that do not use the team tag are the Generals.  Is there a way to make it so

if they have a secondary rank of
[SRB] (group#32)
[STA] (group#33)
[MFR] (group#34)
it would add it to the back of their name.  (if not a member of one of those groups it would be left blank)

Thanks for your time.

-Jacob[/code]

JPDeni

I made a mistake. Sorry. The beginning of it needs to look like this:

global $db_prefix, $scripturl, $txt, $settings, $options;


// These must be in the order you wish them to print out on your roster.
// VERY IMPORTANT!!!! -- they must be exactly the same as the group names in the database, including
// capitalization and spaces. (I notice that "Major" is missing.)
$rankorder = array(
  'General',
  'Brigadier General',
  'Colonel',
  'Lieutenant Colonel',
  'Captain',
  '1st Lieutenant',
  'Sergeant Major',
  'First Sergeant',
  'Master Sergeant',
  'Staff Sergeant',
  'Sergeant',
  'Corporal',
  'Lance Corporal',
  'Private First Class',
  'Private'
);
$abbrev = array(
'General' => 'Gen',
  'Brigadier General' => 'BGen',
  'Colonel' => 'Col',
  'Lieutenant Colonel' => 'LtCol',
  'Captain' => 'Cap',
  '1st Lieutenant' => '1stLt',
  'Sergeant Major' => 'SgtMaj',
  'First Sergeant' => '1stSgt',
  'Master Sergeant' => 'MSgt',
  'Staff Sergeant' => 'SSgt',
  'Sergeant' => 'Sgt',
  'Corporal' => 'Cpl',
  'Lance Corporal' => 'LCpl',
  'Private First Class' => 'PFC',
  'Private'  => 'Pvt'
);

$groups = '';


That should take care of your error. (I'll go fix it in my previous post. I guess I got distracted when I was posting and didn't finish the editing.)

Once that's done, I'd like to get the images taken care of. The teams shouldn't be a problem, especially if we don't have to worry about grouping them by teams.

londonhogfan

ok.  Its working now.  I am amazed at what someone that knows PHP can do.

The stars are still not showing.

have you had a chance to look at the team stuff?

JPDeni

QuoteI am amazed at what someone that knows PHP can do.
:) It's just a matter of breaking down each task into its smallest steps. Computers aren't very smart, so you have to spell it out for them. Where you would tell a person "Go down to the store and get a loaf of bread," you have to tell a computer, "Get up from the couch. Put your hand in your pocket. Get out your keys. Open the door. Walk to the car...." But they do it all really fast.  ;D The coolest thing about databases is that the information is all right there and you can do anything you want with it.

I think I got the image thing figured out.

Change
'stars' => empty($row['stars']) ? '' : $row['stars'],

to

'stars' => empty($row['stars']) ? '' : substr($row['stars'],2),

and change

<center><img src="' . $settings['images_url'] . '/medium/' . $groups[$rank]['stars'] . '"></center></td>';

to

<center><img src="' . $settings['images_url'] . '/' . $groups[$rank]['stars'] . '"></center></td>';

Now, for the teams. I'm assuming that your team designation is stored in the "additionalGroups" field.

Just before

$groups = '';

add


$team[32] = '[SRB]';
$team[33] = '[STA]';
$team[34] = '[MFR]';


Change

    SELECT ID_GROUP, ID_MEMBER, realName, avatar, usertitle,
           emailAddress, hideEmail, lastLogin, location, personalText,
           totalTimeLoggedIn, dateRegistered, ICQ, AIM, YIM, MSN, cs_stats,
           css_stats, hideEmail, emailAddress


to

    SELECT ID_GROUP, ID_MEMBER, realName, avatar, usertitle,
           emailAddress, hideEmail, lastLogin, location, personalText,
           totalTimeLoggedIn, dateRegistered, ICQ, AIM, YIM, MSN, cs_stats,
           css_stats, hideEmail, emailAddress, additionalGroups


and change

        echo '<td class="windowbg" height="40"><a href="' . $scripturl . '?action=profile;u=' . $row2['ID_MEMBER'] . '">-RoTa- ' . $abbrev[$rank] . '|<b><font color="' . $groups[$rank]['color'] . '" size="3" face="verdana">' . $row2['realName'] . '</b></font></font></a><br><font size="1"> ' . $row2['personalText'] . '</font></a></td><td class="windowbg2">' . $row2['usertitle'] . '</td>';


to

        echo '<td class="windowbg" height="40"><a href="' . $scripturl . '?action=profile;u=' . $row2['ID_MEMBER'] . '">-RoTa- ' . $abbrev[$rank] . '|<b><font color="' . $groups[$rank]['color'] . '" size="3" face="verdana">' . $row2['realName'] . '</b>';
if ($row2['additionalGroups'] > 0)
  echo ' '. $team[$row2['additionalGroups']] . ' ';
echo '</font></font></a><br><font size="1"> ' . $row2['personalText'] . '</font></a></td><td class="windowbg2">' . $row2['usertitle'] . '</td>';


If you have trouble with the editing, just let me know and I'll post the whole thing again. Sometimes it's hard to locate things in that much code.

And I'm still working on how to get this down to just two calls to the database. :)

londonhogfan

ok looking good.  Here is the product.
http://www.the-rota.com/?page=64

There are a few people that the team don't show for because they have more than 1 secondary group. (I have way too many groups - Used for permissions)  anyway to get it to work if they are in the group at all?

Thanks again for all your help.

JPDeni

Quoteanyway to get it to work if they are in the group at all?
Yep.

Change
if ($row2['additionalGroups'] > 0)
  echo ' '. $team[$row2['additionalGroups']] . ' ';


to


if ($row2['additionalGroups'] <> '' )
{
  $addl = explode(',',$row2['additionalGroups']);
  foreach ($team as $key => $value)
  {
    if (in_array($key,$addl))
      echo ' '. $value . ' ';
  }
}


I think it's kind of appropriate that we use the "explode" function with all this military stuff. ;D

I'm so glad I finally figured out the image thing. That was bothering me a lot. All it took was actually looking at the source code to figure it out.

If this all works. I'll put together the whole code and rewrite it to make the fewer calls. I think I've got that worked out in my head.

londonhogfan

works :D

here is the final code you came up with...

global $db_prefix, $scripturl, $txt, $settings, $options;


// These must be in the order you wish them to print out on your roster.
// VERY IMPORTANT!!!! -- they must be exactly the same as the group names in the database, including
// capitalization and spaces. (I notice that "Major" is missing.)
$rankorder = array(
  'General',
  'Brigadier General',
  'Colonel',
  'Lieutenant Colonel',
  'Captain',
  '1st Lieutenant',
  'Sergeant Major',
  'First Sergeant',
  'Master Sergeant',
  'Staff Sergeant',
  'Sergeant',
  'Corporal',
  'Lance Corporal',
  'Private First Class',
  'Private'
);
$abbrev = array(
'General' => 'Gen',
  'Brigadier General' => 'BGen',
  'Colonel' => 'Col',
  'Lieutenant Colonel' => 'LtCol',
  'Captain' => 'Cap',
  '1st Lieutenant' => '1stLt',
  'Sergeant Major' => 'SgtMaj',
  'First Sergeant' => '1stSgt',
  'Master Sergeant' => 'MSgt',
  'Staff Sergeant' => 'SSgt',
  'Sergeant' => 'Sgt',
  'Corporal' => 'Cpl',
  'Lance Corporal' => 'LCpl',
  'Private First Class' => 'PFC',
  'Private'  => 'Pvt'
);

$team[32] = '[SRB]';
$team[33] = '[STA]';
$team[34] = '[MFR]';
$groups = '';
//Does all the real work here for showing groups.
$query = db_query("SELECT ID_GROUP, groupName, onlineColor, stars
  FROM {$db_prefix}membergroups", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($query))
{
  $groups[$row['groupName']]  = array(
    'id' => $row['ID_GROUP'],
    'color' => empty($row['onlineColor']) ? '' : $row['onlineColor'],
    'stars' => empty($row['stars']) ? '' : substr($row['stars'],2),
  );
}
mysql_free_result($query);

foreach ($rankorder as $rank)
{
//Now get all the users
  $query2 = db_query("
    SELECT ID_GROUP, ID_MEMBER, realName, avatar, usertitle,
           emailAddress, hideEmail, lastLogin, location, personalText,
           totalTimeLoggedIn, dateRegistered, ICQ, AIM, YIM, MSN, cs_stats,
           css_stats, hideEmail, emailAddress, additionalGroups
    FROM {$db_prefix}members
    WHERE ID_GROUP = '" . $groups[$rank]['id'] . "' ", __FILE__, __LINE__);

  if(db_affected_rows() != 0)
  {
    echo '<table border="0" cellspacing="1" cellpadding="5" align="center" class="bordercolor">
      <tr><td colspan="7" class="catbg"><font size="4" face="verdana"><b>' . $rank . '</b></font></td></tr>
      <tr><td rowspan="70" width="85" class="profilebg" valign="top">
        <center><img src="' . $settings['images_url'] . '/' . $groups[$rank]['stars'] . '"></center></td>';
      echo '<td class="catinfo" width="25"></td>';
      echo '<td class="catinfo" width="245"><b>GAMING ALIAS</b></td>';
      echo '<td class="catinfo" width="130"><b>NAME</b></td>';
      echo '<td class="catinfo" width="170"><b>LAST ONLINE</b></td>';
      echo '<td class="catinfo" width="100"><b>PSYCHOSTATS</b></td>';
      echo '<td class="catinfo" width="175"><b>CONTACT</b></td></tr><tr>';
      while ($row2 = mysql_fetch_assoc($query2))
      {
        echo '<td class="windowbg2 height="40"><img src="http://www.the-rota.com/Themes/default/images/flags/' . $row2['location'] . '.png" alt="' . $row2['location'] . '"></td>';
echo '<td class="windowbg" height="40"><a href="' . $scripturl . '?action=profile;u=' . $row2['ID_MEMBER'] . '">-RoTa- ' . $abbrev[$rank] . '|<b><font color="' . $groups[$rank]['color'] . '" size="3" face="verdana">' . $row2['realName'] . '</b>';
if ($row2['additionalGroups'] <> '' )
{
  $addl = explode(',',$row2['additionalGroups']);
  foreach ($team as $key => $value)
  {
    if (in_array($key,$addl))
      echo ' '. $value . ' ';
  }
}
echo '</font></font></a><br><font size="1"> ' . $row2['personalText'] . '</font></a></td><td class="windowbg2">' . $row2['usertitle'] . '</td>';
        echo '<td class="windowbg">' . timeformat($row2['lastLogin']) . '</td>';
        echo '<td class="windowbg2" align="center">';
        if($row2['cs_stats'] != '')
          echo '<a href="' . $row2['cs_stats'] . '" target="_blank"><img src="' . $settings['images_url'] . '/cs_stats.gif" alt="CS 1.6 Stats" border="0" /></a> ';
        if($row2['css_stats'] != '')
          echo '<a href="' . $row2['css_stats'] . '" target="_blank"><img src="' . $settings['images_url'] . '/css_stats.gif" alt="CS:Source Stats" border="0" /></a> ';
        echo '</td><td class="windowbg">';

//Send email row
        if($row2['hideEmail'] == 0)
          echo '<a href="mailto:', $row2['emailAddress'], '"><img src="' . $settings['images_url'] . '/email_sm.gif" alt="email" /></a> ';

        if($row2['ICQ'] != '')
          echo '<a href="http://www.icq.com/whitepages/about_me.php?uin=' . $row2['ICQ'] . '" target="_blank"><img src="http://status.icq.com/online.gif?img=5&icq=' . $row2['ICQ'] . '" alt="' . $row2['ICQ'] . '" width="18" height="18" border="0" /></a> ';
        if($row2['AIM'] != '')
          echo '<a href="aim:goim?screenname=' . urlencode(strtr($row2['AIM'], array(' ' => '%20'))) . '&message=' . $txt['aim_default_message'] . '"><img src="' . $settings['images_url'] . '/aim.gif" alt="' . $row2['AIM'] . '" border="0" /></a> ';
        if($row2['YIM'] != '')
          echo '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($row2['YIM']) . '"><img src="http://opi.yahoo.com/online?u=' . urlencode($row2['YIM']) . '&m=g&t=0" alt="' . $row2['YIM'] . '" border="0" /></a> ';
        if($row2['MSN'] != '')
          echo '<a href="http://members.msn.com/' . $row2['MSN'] . '" target="_blank"><img src="' . $settings['images_url'] . '/msntalk.gif" alt="' . $row2['MSN'] . '" border="0" /></a> ';

//Send PM row
        echo '<a href="' . $scripturl . '?action=pm;sa=send;u=' . $row2['ID_MEMBER'] . '"><img src="' . $settings['images_url'] . '/im_on.gif" alt="email" /></a></a>';
        echo '</td>';
        echo '</tr>';
      }
    echo '</table><br>';
  }
}

londonhogfan

JPDeni please don't take this as me being greedy, but I would regret it if I didn't ask.

(If your tired of working on this I understand - I can't thank you enough for all your help)

Would it be possible to only show members in certain teams?

I have a team page for each team using Blocs meet the team script (which is "awesome") but it doesn't work very well for what I am using it for.

They are here...
http://www.the-rota.com/?page=48
http://www.the-rota.com/?page=49
http://www.the-rota.com/?page=50

the thing I don't like about them is they are not in rank order and they don't show their full tag.  Is it possible to use the same script you have made here but only show them if they are in a certain group?  I could then just change the group for each team.  That way I will have a clan roster and 3 team rosters that will all look alike.

Again, I can't thank you enough for your help.

-Jacob

This website is proudly hosted on Crocweb Cloud Website Hosting.