Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Re: GROUP BY problems

Quote Reply
Re: GROUP BY problems In reply to
Well, I found out that the UNKNOWN TAGS were actually for the forum categories....

Now, my forum looks like:

Category1
Category2
Category3
-------------
Forum1
Forum2
Forum3
Forum4
Forum5
Forum6
Forum7
Forum8

etc...

And the forums are "grouped"/"sorted" by forum category, but the categories all print at the top of the forum page, with the forums at the bottom.

You can see at:

http://www.anthrotech.com/...forum/testindex2.cgi

I did rewrite the queries to look like the following:

Code:

sub display {
# --------------------------------------------------------
my ($in, $dynamic) = @_;
my %OUT;
my ($author, $forum, $forumcat, $forumcatid, $forumdesc, $forumid, $getforum, $moderator, $output, $posts, $rec, $showfcat, $showforums, $status, $updated, $userperm);
my $s = $in->param('s') || $in->cookie('s');
$USER = &authenticate ($s);
my $title_linked = &build_linked_forum_title ("Anthro TECH Discussion Forum");

my $sth = $FORUMCATDB->prepare ("SELECT * FROM Forum_Cats GROUP BY ForumCatName");
$sth->execute() or die $DBI::errstr;
while (my $rec = $sth->fetchrow_hashref) {
$OUT{Categories} .= &site_html_forumcat_link ($rec);
my $sti = $FORUMSDB->prepare ("SELECT * FROM Forum_Topics WHERE ForumCatID = ${$rec}{ForumCatID} ORDER BY ForumName");
$sti->execute() or die $DBI::errstr;
while (my $rec = $sti->fetchrow_hashref) {
$moderator = $rec->{ModeratorID};
undef $Links::DBSQL::DBH;
my $user = $USERDB->get_record ($moderator, 'HASH');
foreach (keys %$user) {
$rec->{$_} = $user->{$_};
}
$OUT{Topics} .= &site_html_forum_link ($rec);
}
}
if (defined $USER) {
&site_html_forum_home ({Username => $USER{Username}, title_linked => $title_linked, %$USER, %OUT}, $dynamic);
}
else {
&site_html_forum_home ({title_linked => $title_linked, %OUT}, $dynamic);
}
}


Basically...an extension from what Jerry Su wrote awhile back....

I bet that the problem could be in the template file, which the forum home template file looks like the following:

Code:

<html>
<head>
<title><%site_title%></title>
<%site_header%>
<%title_linked%>
<%if Categories%>
<%if Topics%>

<p>
<span class="header">Welcome
<%if Username%>
<%Username%>!
</span>
<span class="smtext">
If you are not <%Username%>,
<span class="boldtext"><a href="<%build_logout_url%>">Logout</a>!
</span>
<%endif%>
<%ifnot Username%>
Guest User!
</span>
<span class="smboldtext">
<a href="<%build_login_url%>">Login</a> -
<a href="<%build_signup_url%>">Register Account</a>
</span>
<%endif%>
<p>
<div align="center"><center>
<table border="1" width="100%" cellpadding="2" cellspacing="0">
<%Categories%>
<tr bgcolor="00009c">
<td valign="top" width="60%">
<span class="subwhiteheader">Forum</span>
</td>
<td valign="top" width="10%">
<span class="subwhiteheader">Type</span>
</td>
<td valign="top" width="15%">
<span class="subwhiteheader">Moderator</span>
</td>
<td valign="top" width="15%">
<span class="subwhiteheader">Post History</span>
</td></tr>
<%Topics%>
</table>
</div></center>
<%endif%>
<%endif%>

<%site_footer%>


I have two other template files (referenced by <%Categories%> and <%Topics%> tags)....

forumcatlink.html --> Categories

Code:

<tr bgcolor="000000">
<td valign="top" width="100%" colspan="4">
<span class="subwhiteheader"><%ForumCatName%></span>
</td></tr>


forumlink.html --> Topics

Code:

<tr bgcolor="FFFFCC">
<td valign="top" width="60%">
<span class="boldtext">
<a href="<%build_forum_url%>?topics=<%ForumID%>"><%ForumName%></a>
</span>
<%if ForumDescription%>


<span class="smtext"><%ForumDescription%></span>
<%endif%>
</td>
<td valign="top" width="10%">
<span class="text"><%ForumStatus%></span>
</td>
<td valign="top" width="15%">
<span class="text">
<%if Username_Permission eq 'Y'%>
<%if Author%>
<a href="<%build_userdetail_url%>?ID=<%ModeratorID%>"><%Author%></a>
<%endif%>
<%ifnot Author%>
<a href="<%build_userdetail_url%>?ID=<%ModeratorID%>">Not Provided</a>
<%endif%>
<%endif%>
<%if Username_Permission eq 'N'%>
<a href="<%build_userdetail_url%>?ID=<%ModeratorID%>">Anonymous</a>
<%endif%>
</span>
</td>
<td valign="top" width="15%">
<span class="boldtext">
<%if NumberPosts eq '0'%>
<%NumberPosts%> Posts
<%endif%>
<%if NumberPosts eq '1'%>
<%NumberPosts%> Post
<%endif%>
<%if NumberPosts gt '1'%>
<%NumberPosts%> Posts
<%endif%>
</span>
<%if ForumNew eq 'Y'%>
<%nbsp%><%new1img%>
<%endif%>


<span class="smtext">
<span class="smboldtext">Last Updated:</span> <%Last_Updated%>
</span>
</td></tr>


Regards,

Eliot Lee
Subject Author Views Date
Thread GROUP BY problems Stealth 6109 Jul 8, 2001, 3:30 PM
Thread Re: GROUP BY problems
sponge 5965 Jul 8, 2001, 11:35 PM
Thread Re: GROUP BY problems
Stealth 5961 Jul 10, 2001, 5:44 PM
Thread Re: GROUP BY problems
sponge 5967 Jul 10, 2001, 7:53 PM
Thread Re: GROUP BY problems
Stealth 5958 Jul 10, 2001, 8:12 PM
Thread Re: GROUP BY problems
sponge 5953 Jul 11, 2001, 1:41 AM
Thread Re: GROUP BY problems
Stealth 5944 Jul 11, 2001, 4:54 PM
Thread Re: GROUP BY problems
sponge 5909 Jul 21, 2001, 8:20 PM
Thread Re: GROUP BY problems
Stealth 5910 Jul 22, 2001, 9:41 PM
Thread Re: GROUP BY problems
sponge 5907 Jul 22, 2001, 11:41 PM
Post Re: GROUP BY problems
Stealth 5888 Jul 23, 2001, 7:41 AM