*

Recent

Author Topic: Memberlist - Sortable  (Read 6857 times)

andrew

  • Newbie
  • *
  • Posts: 36
  • Force: +0/-0
Memberlist - Sortable
« on: January 02, 2010, 03:39:02 PM »
The memberlist should be sortable by plays, as wel as by ID and by username :)

like how in SMF you can view by post count, join date or Username

Just saying ;) :)
http://tcxgames.com  My arcade.

[Donated]

kurt

  • Developer
  • Hero Member
  • ******
  • Posts: 634
  • Force: +16/-1
Re: Memberlist - Sortable
« Reply #1 on: January 02, 2010, 03:51:18 PM »
Yea, it would be a nice thing to have wouldn't it? Have to keep that one in the back of our minds thinking it over as to how to best go about doing it.

Thanks.

Adam LaCombe

  • Sr. Member
  • ****
  • Posts: 433
  • Force: +17/-0
    • My Blog
Re: Memberlist - Sortable
« Reply #2 on: January 04, 2010, 04:34:44 PM »
OK I got what I think you wanted..
You wanted it so you could order low to high/high to low for id,username, and plays. right?

if so try this out:
Code: [Select]
<?php


function writebody() {
global 
$db$domain$sitename$domain$template$gamesfolder$thumbsfolder$limitboxgames$seo_on$blogentriesshown$enabledcode_on$comments_on$directorypath$autoapprovecomments$gamesonpage$abovegames$belowgames$showwebsitelimit$supportemail$showblog$blogentriesshown$blogcharactersshown$blogcommentpermissions$blogcommentsshown$blogfollowtags$blogcharactersrss$usrdata$userid;



$orderby=clean($_GET['orderby']);
$max '70';
$show clean($_GET['page']);
if(empty(
$show)){
$show 1;
}
$limits = ($show 1) * $max

if(
$orderby){
if(
$orderby == "playshl"){
$r $db->query(sprintf("SELECT * FROM dd_users ORDER BY plays DESC LIMIT $limits,$max"));
}
if(
$orderby == "usernamehl"){
$r $db->query(sprintf("SELECT * FROM dd_users ORDER BY username DESC LIMIT $limits,$max"));
}
if(
$orderby == "idlh"){
$r $db->query(sprintf("SELECT * FROM dd_users ORDER BY userid ASC LIMIT $limits,$max"));
}

if(
$orderby == "playslh"){
$r $db->query(sprintf("SELECT * FROM dd_users ORDER BY plays ASC LIMIT $limits,$max"));
}
if(
$orderby == "usernamelh"){
$r $db->query(sprintf("SELECT * FROM dd_users ORDER BY username ASC LIMIT $limits,$max"));
}
if(
$orderby == "idhl"){
$r $db->query(sprintf("SELECT * FROM dd_users ORDER BY userid DESC LIMIT $limits,$max"));
}
}else{
$r $db->query(sprintf("SELECT * FROM dd_users ORDER BY username ASC LIMIT $limits,$max"));
}

$totalres mysql_result($db->query('SELECT COUNT(userid) AS total FROM dd_users'),0); 
$totalpages ceil($totalres $max); 
echo 
'

<table width="89%" align="center">
<tr>
<td colspan=\'4\' class=\'header\'>User List</td>
</tr>
<tr>
<th class="header"># <a href=\''
.$domain.'/index.php?action=memberslist&orderby=idlh\'>D</a> - <a href=\''.$domain.'/index.php?action=memberslist&orderby=idhl\'>U</a></th>
<th class="header">Name <a href=\''
.$domain.'/index.php?action=memberslist&orderby=usernamelh\'>D</a> - <a href=\''.$domain.'/index.php?action=memberslist&orderby=usernamehl\'>U</a></th>
<th class="header">Plays <a href=\''
.$domain.'/index.php?action=memberslist&orderby=playslh\'>D</a> - <a href=\''.$domain.'/index.php?action=memberslist&orderby=playshl\'>U</a></th>
<th class="header"> </th>
</tr>'
;
while(
$ir $db->fetch_row($r)){
$useridl=$ir['userid'];
if(
$seo_on == 1){
$urlp ''.$domain.'/showprofile/'.$useridl.'.html';
}else{
$urlp ''.$domain.'/index.php?action=showprofile&profile='.$useridl ;
}



echo 
' <tr>
<td class="content">'
.$ir['userid'].'</td>
<td class="content">'
.$ir['username'].'</td>
<td class="content">'
.$ir['plays'].'</td>
<td class="content"><a href="'
.$urlp.'">View Profile</a></td>
</tr>'
;
}

echo 
'</table>
<div align="center">Pages: '
;
for(
$i 1$i <= $totalpages$i++){ 
if(
$seo_on == 1){
$urlmp ''.$domain.'/memberslist/'.$i.'.html';
}else{
$urlmp ''.$domain.'/index.php?action=memberslist&page='.$i ;
}


echo 
'<a href="'.$urlmp.'" class="pagenat">'.$i.'</a>&nbsp;';

}
echo 
'<p></div>';

};


$pagetitle $sitename.' member list';
$metatags 'members, member list';
$metadescription $sitename.' member list';
?>


Just replace memberslist.php with whats above (always make sure you have a backup of the original file though!)

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: Memberlist - Sortable
« Reply #3 on: September 05, 2011, 08:56:55 PM »
ok i made a few changes to this post and got everything i needed working but i have a section with online/offline and thats not in the database so i cant sort it using the database. Is there a way i can sort that?

Code: [Select]
<?php


function writebody() {
global 
$db$domain$sitename$domain$template$gamesfolder$thumbsfolder$limitboxgames$seo_on$blogentriesshown$enabledcode_on$comments_on$directorypath$autoapprovecomments$gamesonpage$abovegames$belowgames$showwebsitelimit$supportemail$showblog$blogentriesshown$blogcharactersshown$blogcommentpermissions$blogcommentsshown$blogfollowtags$blogcharactersrss$usrdata$userid;



$orderby=clean($_GET['orderby']);
$max '70';
$show clean($_GET['page']);
if(empty(
$show)){
$show 1;
}
$limits = ($show 1) * $max

if(
$orderby){
if(
$orderby == "playshl"){
$r $db->query(sprintf("SELECT * FROM dd_users WHERE activation_key='0' ORDER BY plays DESC LIMIT $limits,$max"));
}
if(
$orderby == "usernamehl"){
$r $db->query(sprintf("SELECT * FROM dd_users WHERE activation_key='0' ORDER BY username DESC LIMIT $limits,$max"));
}
if(
$orderby == "ranklh"){
$r $db->query(sprintf("SELECT * FROM dd_users WHERE activation_key='0' ORDER BY user_level ASC LIMIT $limits,$max"));
}

if(
$orderby == "playslh"){
$r $db->query(sprintf("SELECT * FROM dd_users WHERE activation_key='0' ORDER BY plays ASC LIMIT $limits,$max"));
}
if(
$orderby == "usernamelh"){
$r $db->query(sprintf("SELECT * FROM dd_users WHERE activation_key='0' ORDER BY username ASC LIMIT $limits,$max"));
}
if(
$orderby == "rankhl"){
$r $db->query(sprintf("SELECT * FROM dd_users WHERE activation_key='0' ORDER BY user_level DESC LIMIT $limits,$max"));
}
}else{
$r $db->query(sprintf("SELECT * FROM dd_users WHERE activation_key='0' ORDER BY username ASC LIMIT $limits,$max"));
}

$totalres mysql_result($db->query('SELECT COUNT(userid) AS total FROM dd_users'),0); 
$totalpages ceil($totalres $max); 
echo 
'

<table width="89%" align="center">
<tr>
<th class="header">Name <a href=\''
.$domain.'/index.php?action=memberslist&orderby=usernamelh\'>D</a> - <a href=\''.$domain.'/index.php?action=memberslist&orderby=usernamehl\'>U</a></th>
<th class="header">Plays <a href=\''
.$domain.'/index.php?action=memberslist&orderby=playslh\'>D</a> - <a href=\''.$domain.'/index.php?action=memberslist&orderby=playshl\'>U</a></th>
<th class="header">Status <a href=\''
.$domain.'/index.php?action=memberslist&orderby=playslh\'>D</a> - <a href=\''.$domain.'/index.php?action=memberslist&orderby=playshl\'>U</a></th>
<th class="header">Rank <a href=\''
.$domain.'/index.php?action=memberslist&orderby=rankhl\'>D</a> - <a href=\''.$domain.'/index.php?action=memberslist&orderby=ranklh\'>U</a></th>
</tr>'
;
while(
$ir $db->fetch_row($r)){
$useridl=$ir['userid'];
if(
$seo_on == 1){
$urlp ''.$domain.'/showprofile/'.$useridl.'.html';
}else{
$urlp ''.$domain.'/index.php?action=showprofile&profile='.$useridl ;
}


if (
$ir['user_level'] == '1') { // PHP If Statement
  
$rank='Member';
} elseif (
$ir['user_level'] == '2') { // PHP Elseif Statement
  
$rank='<font color=red>Admin</font>';
} else {
  
$rank='Guest'// PHP Else
}

if(
$ir['status'] >= time()-15*60){
$status='<font color=green>Online!</font>';
}else{
$status='<font color=red>Offline!</font>';
}

echo 
' <tr>
<td class="content"><a href="'
.$urlp.'">'.$ir['username'].'</a></td>
<td class="content">'
.$ir['plays'].'</td>
<td class="content">'
.$status.'</td>
<td class="content">'
.$rank.'</td>
</tr>'
;
}

echo 
'</table>
<div align="center">Pages: '
;
for(
$i 1$i <= $totalpages$i++){ 
if(
$seo_on == 1){
$urlmp ''.$domain.'/memberslist/'.$i.'.html';
}else{
$urlmp ''.$domain.'/index.php?action=memberslist&page='.$i ;
}


echo 
'<a href="'.$urlmp.'" class="pagenat">'.$i.'</a>&nbsp;';

}
echo 
'<p></div>';

};


$pagetitle $sitename.' member list';
$metatags 'members, member list';
$metadescription $sitename.' member list';
?>

kurt

  • Developer
  • Hero Member
  • ******
  • Posts: 634
  • Force: +16/-1
Re: Memberlist - Sortable
« Reply #4 on: September 11, 2011, 01:17:51 PM »
Looks good, thanks.

Tracking whether or not a member is online or not is something I believe Adam is working on for 2.1. You might want to download it and see if its something you can adapt to what you have.