View Full Version : custom sort of the memberlist
banjolawyer
09-02-2002, 02:41 PM
The hyperlink for listing members by a particular field is, for example
quote:
--------------------------------------------------------------------------------
http://xxx/forums/memberlist.php?s=&what=field1
--------------------------------------------------------------------------------
I have added three custom fields to my user table, and will display those on the memberlist. (For example, firstname, lastname, graduationyear)
I would like rewrite the hyperlink for the "members" button, so that, when clicked, the resulting list is sorted by
1st - graduationyear
2nd - lastname
3rd - firstname
Can anyone tell me what my hyperlink should look like?
banjolawyer
09-02-2002, 05:01 PM
OK; I've determined that what I really should be changing in the code in memberlist.php
I did this:
$orderby=gradyear;
and it worked
However, I don't know the syntax for adding additional fields. Can anyone help me?
I've tried
$orderby=gradyear,lastname,firstname;
and
$orderby=gradyear and lastname and firstname;
And neither worked.
Boofo
09-02-2002, 05:31 PM
Did you try
$orderby=gradyear&$orderby=lastname&$orderby=firstname
banjolawyer
09-02-2002, 06:32 PM
That produced the following error:
Invalid SQL: SELECT *
FROM user,userfield
WHERE 1=1 AND
user.userid = userfield.userid
AND usergroupid NOT IN (1,3,4)
ORDER BY d`````a` ASC
LIMIT 0,1000
mysql error: You have an error in your SQL syntax near '````a` ASC
LIMIT 0,1000' at line 6
mysql error number: 1064
Boofo
09-02-2002, 06:38 PM
What is the full link you were using that worked? Adn what are the names of the fields you added to the db for the variables?
banjolawyer
09-02-2002, 06:58 PM
The hyperlink to the memberlist is the standard link
http://mysite.net/forums/memberlist.php?s=
I added the following fields to the db:
gradyear
firstname
lastnameold
and I modified register.php and registeradult template to force new users to provide that info. I've tested that out, no problems there.
I changed code in memberlist.php from:
if ($orderby=="" or ($orderby!="username" and $orderby!="posts" and $orderby!="joindate" and $orderby!="lastpost")) {
$orderby=username;
to:
if ($orderby=="" or ($orderby!="username" and $orderby!="posts" and $orderby!="joindate" and $orderby!="lastpost" and $orderby!="lastnameold")) {
$orderby=gradyear;
and that works fine also, but it only sorts by gradyear.
I am displaying the memberlist
1st column gradyear
2nd column lastnameold
3rd column firstname
4th column username
etc.
When I signup test users from the same year, Jones and Adams from 1988 are listed before the 1992 people, but Jones gets listed before Adams.
Boofo
09-02-2002, 07:08 PM
I'm just guessing here but see if this will work.
if ($orderby=="" or ($orderby!="username" and $orderby!="posts" and $orderby!="joindate" and $orderby!="lastpost" and $orderby!="lastnameold")) {
$orderby=gradyear;
$orderby=lastnameold;
$$orderby=firstname;
$orderby=username;
or however order you wanted. Let me know if this does anything.
banjolawyer
09-02-2002, 07:26 PM
What happens here is that it just skips right down to the last orderby and sorts by the username. Thanks for your help. I am going to give up for the day.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.