#!/usr/bin/perl -Tw ############################################################ ## Written and copyright 2002 by ## Jacqueline D. Hamilton (kira@cgi101.com) ## ## This code is excerpted from "CGI Programming 201" ## (http://www.cgi101.com/advanced) ## ## You may use this code on your own website, however ## you may not publish or sell any copy or derivative work ## without permission of the author. ############################################################# use lib '.'; use MyBoard; use strict; &do_header("Forums"); print qq(

My Forums

\n); my($sth) = $dbh->prepare("select forums.id, name, description, count(messages.id) as msgcount from forums left join messages on forums.id = messages.forum group by forums.id order by rank, name") or &dbdie; my($rv) = $sth->execute; my($f); while ($f = $sth->fetchrow_hashref) { my($msg) = "message"; if ($f->{msgcount} != 1) { $msg .= "s"; } print qq($f->{name} ($f->{msgcount} $msg) - $f->{description}

\n); } &do_footer;