Web Wiz - Green Windows Web Hosting - Celebrating 25 Years!

  New Posts New Posts RSS Feed - Query Question
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Query Question

 Post Reply Post Reply Page  123>
Author
felix.akinyemi View Drop Down
Groupie
Groupie
Avatar

Joined: 09 December 2004
Location: United States
Status: Offline
Points: 113
Post Options Post Options   Thanks (0) Thanks(0)   Quote felix.akinyemi Quote  Post ReplyReply Direct Link To This Post Topic: Query Question
    Posted: 21 July 2005 at 9:57am
Question:

Is there a way to get all the moderators for a forum with just one query, i have tried all the ways i thought might work but still no luck!!

Has anyone got any other ways!!
Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post Posted: 21 July 2005 at 10:02am
SELECT tblAuthor.Username FROM tblAuthor WHERE tblAuthor.Group_ID = tblGroup.Group_ID AND tblGroup.Group_type = 3

on those lines should work

it says get the username from the author table where the Author group ID = the groups table ID, and where the group type  = 3

i think 3 is Moderator

that should help
Back to Top
felix.akinyemi View Drop Down
Groupie
Groupie
Avatar

Joined: 09 December 2004
Location: United States
Status: Offline
Points: 113
Post Options Post Options   Thanks (0) Thanks(0)   Quote felix.akinyemi Quote  Post ReplyReply Direct Link To This Post Posted: 21 July 2005 at 10:07am
Haven't tried that yet but it looks like its only getting authors, i meant for the default.asp page, where it displays the list of moderators under the forum, i need to get all the groups and authors assign to the forum to moderate it!!
Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post Posted: 21 July 2005 at 10:43am
SELECT tblAuthor.Username FROM tblAuthor WHERE tblAuthor.Group_ID = tblGroup.Group_ID AND (( tblPermissions.Moderate = True AND tblGroupID = tblPermssions.Group_ID) OR (tblPermissions.Moderate = True AND tblGroupID = tblPermssions.Group_ID AND tblPermssions.Author_ID = lngLoggedInUserID)) AND tblPermissions.Forum_ID=" & intForumID & "


on those lines i think is what you want, the field names im not sure on, but something like that.
Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post Posted: 21 July 2005 at 10:57am
you may want to add tblAuthor.Author_ID within the select part so you can have a pop up profile
Back to Top
felix.akinyemi View Drop Down
Groupie
Groupie
Avatar

Joined: 09 December 2004
Location: United States
Status: Offline
Points: 113
Post Options Post Options   Thanks (0) Thanks(0)   Quote felix.akinyemi Quote  Post ReplyReply Direct Link To This Post Posted: 21 July 2005 at 10:58am
oh i see what you mean but... OK this is wat i mean, should have done this first, ma bad!!


'Get the List of Group Moderators for the Forum
If blnShowMod Then
   
    'Initalise the strSQL variable with an SQL statement to query the database to get the moderators for this forum
    If strDatabaseType = "SQLServer" Then
        strSQL = "EXECUTE " & strDbProc & "ModeratorGroup @intForumID = " & intForumID
    Else
        strSQL = "SELECT " & strDbTable & "Group.Group_ID, " & strDbTable & "Group.Name "
        strSQL = strSQL & "FROM " & strDbTable & "Group, " & strDbTable & "Permissions "
        strSQL = strSQL & "WHERE " & strDbTable & "Group.Group_ID = " & strDbTable & "Permissions.Group_ID AND " & strDbTable & "Permissions.Moderate = True AND " & strDbTable & "Permissions.Forum_ID = " & intForumID & ";"

    End If

    'Query the database
    rsCommon.Open strSQL, adoCon

    'Initlaise the Moderators List varible if there are records returned for the forum
    If NOT rsCommon.EOF Then strModeratorsList = "<br /><span class=""smText"">" & strTxtModerators & ":</span>"

    'Loop round to build a list of moderators, if there are any
    Do While NOT rsCommon.EOF

        'Place the moderators username into the string
        strModeratorsList = strModeratorsList & " <a href=""members.asp?GID=" & rsCommon("Group_ID") & """ class=""smLink"">" & rsCommon("Name") & "</a>"

        'Move to the next record
        rsCommon.MoveNext
    Loop

    'Close the recordset
    rsCommon.Close
   
   
   
    'Initalise the strSQL variable with an SQL statement to query the database to get the moderators for this forum
    If strDatabaseType = "SQLServer" Then
        strSQL = "EXECUTE " & strDbProc & "Moderators @intForumID = " & intForumID
    Else
        strSQL = "SELECT " & strDbTable & "Author.Author_ID, " & strDbTable & "Author.Username "
        strSQL = strSQL & "FROM " & strDbTable & "Permissions, " & strDbTable & "Author "
        strSQL = strSQL & "WHERE " & strDbTable & "Author.Author_ID = " & strDbTable & "Permissions.Author_ID AND " & strDbTable & "Permissions.Moderate = True AND " & strDbTable & "Permissions.Forum_ID = " & intForumID & ";"

    End If

    'Query the database
    rsCommon.Open strSQL, adoCon

    'Initlaise the Moderators List varible if there are records returned for the forum
    If NOT rsCommon.EOF AND strModeratorsList = "" Then strModeratorsList = "<br /><span class=""smText"">" & strTxtModerators & ":</span>"

    'Loop round to build a list of moderators, if there are any
    Do While NOT rsCommon.EOF

        'Place the moderators username into the string
        strModeratorsList = strModeratorsList & " <a href=""JavaScript:openWin('pop_up_profile.asp?PF=" & rsCommon("Author_ID") & "','profile','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=590,heig ht=425')"" class=""smLink"">" & rsCommon("Username") & "</a>"

        'Move to the next record
        rsCommon.MoveNext
    Loop

    'Close the recordset
    rsCommon.Close
End If



need to compress both queries into one query!!
Back to Top
felix.akinyemi View Drop Down
Groupie
Groupie
Avatar

Joined: 09 December 2004
Location: United States
Status: Offline
Points: 113
Post Options Post Options   Thanks (0) Thanks(0)   Quote felix.akinyemi Quote  Post ReplyReply Direct Link To This Post Posted: 21 July 2005 at 11:08am

strSQL = "SELECT " & strDbTable & "Group.Group_ID, " & strDbTable & "Group.Name "
strSQL = strSQL & "FROM " & strDbTable & "Group, " & strDbTable & "Permissions "
strSQL = strSQL & "WHERE " & strDbTable & "Group.Group_ID = " & strDbTable & "Permissions.Group_ID AND " & strDbTable & "Permissions.Moderate = True AND " & strDbTable & "Permissions.Forum_ID = " & intForumID & ";"


AND



strSQL = "SELECT " & strDbTable & "Author.Author_ID, " & strDbTable & "Author.Username "
strSQL = strSQL & "FROM " & strDbTable & "Permissions, " & strDbTable & "Author "
strSQL = strSQL & "WHERE " & strDbTable & "Author.Author_ID = " & strDbTable & "Permissions.Author_ID AND " & strDbTable & "Permissions.Moderate = True AND " & strDbTable & "Permissions.Forum_ID = " & intForumID & ";"




Then 2
Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post Posted: 21 July 2005 at 11:40am
strSQL = "SELECT " & strDbTable & "Group.Group_ID, " & strDbTable & "Group.Name, " & strDbTable & "Author.Author_ID, " & strDbTable & "Author.Username "
strSQL = strSQL & "FROM " & strDbTable & "Permissions, " & strDbTable & "Group, " & strDbTable & "Author "
strSQL = strSQL & "WHERE " & strDbTable & "Author.Author_ID
= " & strDbTable & "Permissions.Author_ID AND " &
strDbTable & "Permissions.Moderate = True AND " & strDbTable
& "Permissions.Forum_ID = " & intForumID & " AND " & strDbTable & "Group.Group_ID = " & strDbTable & "Author.Author_ID ORDER BY " & strDbTable & "Author.Username;"

dim blnFirst
dim intMODGroupID
blnFirst = True
then you need ot do a check
do while NOT rsCommon.eof
intMODGroupID = rsCommon("Group_ID")

if rsCommon("Group_ID") <> intMODGroupID OR blnFirst= True then

strModeratorsList = "<a href=""members.asp?GID=" & rsCommon("Group_ID") & """>" & rsCommon("Group_name") & "</a> :"
blnFirst = False
END IF

        strModeratorsList =
strModeratorsList & " <a
href=""JavaScript:openWin('pop_up_profile.asp?PF=" &
rsCommon("Author_ID") &
"','profile','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=590,heig ht=425')""
class=""smLink"">" & rsCommon("Username") & "</a>"

rsCommon.movenext

loop


of course you need to do a check before thats done making sure there are records to prevent errors.

that will give a list like

GroupName : username username Group Name : userame username


i aven't tested it in any way apart from in my head but should help
Back to Top
 Post Reply Post Reply Page  123>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.