Admin Email List - Sorting Option - Posted (2839 Views)
Average Member
Andy Humm
Posts: 908
908
Using the admin_emaillist.asp I notice that the listing is centered around the user name and sorted by their MEMBER_ID. Initially I have changed the sort option from the Member_ID to sort the list by the Members Name alphabetically. (M_NAME) You will see the four options I have added, three which have been commented for reference.

admin_emaillist.asp lines 59-64
'## Forum_SQL - Find all records with the search criteria in them
strSql = "SELECT M_NAME, M_EMAIL, M_POSTS "
strSql2 = " FROM " & strMemberTablePrefix & "MEMBERS "
strSql3 = " WHERE M_STATUS = " & 1
strSql4 = " ORDER BY M_NAME ASC " '##sort by member name
'strSql4 = " ORDER BY MEMBER_ID ASC " '##sort by member id
'strSql4 = " ORDER BY M_POSTS ASC " '##sort by number of posts
'strSql4 = " ORDER BY M_EMAIL ASC " '##sort by email address


To make the admail_emaillist.asp more flexible to the user, I am looking to add a pull down option where we can select the sort choice based on a value from strSql4. I have grabbed this piece of code and adjusted the names in option colours. I wonder if someone could assist is showing us how to tie the option box so that we utilise the different strSql4's. I am stumped here how to tie the two together maybe an 'if' statement is required..
Secondly I will be looking to add this new option box on the same line as the NOTE: The following table will show you a list of all users of this forum, and their e-mail addresses.
Any further help will be appreciated.
" <select style=""width:140;"" name=""emailsort"">" & VBNewLine & _
" <option value=""0""" & checkSelect(stremailsort,"0") & ">" Sort by User name "</option>" & VBNewLine & _
" <option value=""1""" & checkSelect(stremailsort
,"1") & ">" Sort by Member ID "</option>" & VBNewLine & _
" <option value=""2""" & checkSelect(stremailsort,"2") & ">" Sort by Posts "</option>" & VBNewLine & _
" <option value=""3""" & checkSelect(stremailsort,"3") & ">" Sort by Posts "</option>" & VBNewLine & _
" </select>" & VBNewLine & _

Thank you andy

<
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
Advanced Member
Carefree
Posts: 4224
4224
Let's start with the easy one. See this line?
Code:
" <option value=""3""" & checkSelect(stremailsort,"3") & ">" Sort by Posts "</option>" & VBNewLine & _

I'm fairly sure you mean "Sort by Email Address ".
Back to the initial query. Using an if/then series; you could do something like this:
Code:
Option Explicit
strSort = Request.Form("emailsort")
if strSort > "" then
if strSort = "0" then strSql4 = " ORDER BY M_NAME ASC "
else if strSort = "1" then strSql4 = " ORDER BY MEMBER_ID ASC "
else if strSort = "2" then strSql4 = " ORDER BY M_POSTS ASC "
else strSql4 = " ORDER BY M_EMAIL ASC "
end if
strSql = "SELECT M_NAME, M_EMAIL, M_POSTS "
strSql2 = " FROM " & strMemberTablePrefix & "MEMBERS "
strSql3 = " WHERE M_STATUS = " & 1




All the stuff you want to do with the results in here...


else
" <select style=""width:140;"" name=""emailsort"">" & VBNewLine & _
" <option value=""0""" & checkSelect(stremailsort,"0") & ">" Sort by User Name "</option>" & VBNewLine & _
" <option value=""1""" & checkSelect(stremailsort,"1") & ">" Sort by Member ID "</option>" & VBNewLine & _
" <option value=""2""" & checkSelect(stremailsort,"2") & ">" Sort by Posts "</option>" & VBNewLine & _
" <option value=""3""" & checkSelect(stremailsort,"3") & ">" Sort by EMail "</option>" & VBNewLine & _
" </select>" & VBNewLine & _
end if

However, I believe that if you get this mod, it'll save you a lot of work: EMail Search <
Posted
Average Member
Andy Humm
Posts: 908
908
Carefree absolutely quick on the response and I thank you.. Yes the 'easy one' you were right in my intenstions, missed it on the cut and paste.. Just the hard bit now getting this routine incorporated in the page. Ideally I would like to add the option pull down into the page on the same line as the NOTE: The following table will show you a list of all users of this forum, and their e-mail addresses. thank you so far
BTW here is my admin_emaillist.asp text link for reference
<
Posted
Average Member
Andy Humm
Posts: 908
908
Further to above, I have created a new cell where I would like the option box placed on image where the 'ss' is (top left corner)


The code around the table head is:
Code:
		"        </tr>" & vbNewLine & _
" <tr>" & vbNewLine & _
" <td width=""20%"" ><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """>ss</td>" & vbNewLine & _
" <td align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """>The following table shows a list of all users of this forum, and their e-mail addresses.</font></td>" & vbNewLine
if maxpages > 1 then
Response.Write " <td width=""15%"" align=""right"">" & vbNewLine & _
" <table border=""0"" align=""right"">" & vbNewLine & _
" <tr>" & vbNewLine
Call DropDownPaging(1)
Response.Write " </tr>" & vbNewLine & _
" </table>" & vbNewLine & _
" </td>" & vbNewLine
end if
<
Posted
Advanced Member
Carefree
Posts: 4224
4224
Here you go - I have everything done except the selection isn't being sent to the form for action.
EMail List<
Posted
Average Member
Andy Humm
Posts: 908
908
So far we are getting a little further, thank you carefree.. The page link you provided has a few table formating differences, which I have revamped to the latest. As carefree has said we have a pull down option box but it is not functioning to do the sort. Can anyone assist in our pursuit.. This is what we have:

And the admin_emaillist.asp latest code is here
The lines associated with the changes so far:
59-81 sql
153-159 Option Box

Thank you andy
<
Posted
Average Member
Andy Humm
Posts: 908
908
Carefree
Initially when I tried your suggested code, I did have a few display errors, ie fonts and layout was peculiar. Looking at the code again, I noticed the following:
" </table" & vbNewLine & _
"<form method=""post"" ID=""EMSR"" action
Apologies I have no line numbers as I do not have access to my main computer with editing software..
If table tag is wrong ie </table> and this sorts the layout, could we remove the Member_ID column and stay with the original three coloumns (Member Name, Email Address and Posts)
I wonder if we can get the pulldown option to work. Thank you
Andy<
Posted
Advanced Member
Carefree
Posts: 4224
4224
I'll have the pull-down working today. I'll send you the new code in the next couple of hours.<
Posted
Average Member
Andy Humm
Posts: 908
908
cheers<
Posted
Advanced Member
Carefree
Posts: 4224
4224
Well, I have the page number pull-down fixed. The sorter is missing something important.
Email List<
Posted
Average Member
Andy Humm
Posts: 908
908
We had problems getting onto snitz since yesterday and hey presto were back online. At the moment I am not at worksation with access to my forum software.

Carefree: Can yoy confirm the latest txt version is working with the sorter pulldown working for the sorts as you state "I have the page number pull-down fixed. The sorter is missing something important".
Secondly, has this new code remove the Member_ID column? Thank you so much
Andy<
You Must enter a message