Gossamer Forum
Quote Reply
Show user gender
Hi Andy,
I have this global to show the gender on my site

Code:
sub {

use lib '/www/community/private/lib';

my $NEWDB = new GT::SQL (
def_path => '/www/community/private/defs',
cache => 0,
debug => 0,
subclass => 0
);

my $db = $NEWDB->table('comm_users');
$db->select_options( "GROUP BY prof_gender","ORDER BY gender_count DESC");
my $sth = $db->select("prof_gender", "COUNT(*) as gender_count") or die "Query Error: $GT::SQL::error";

my @genders;
while (my ($s, $c) = $sth->fetchrow_array) {

push @genders, { Name => $s, count => $c }
}

return { gender_loop_count => \@genders }

}


Code:
<%user_gender%>

<ul>
<%loop gender_loop_count%>
<li><%Name%> - <%count%></li>
<%endloop%>
</ul>


I have two problems with this global
It prints out

0 - 1115
1 - 791

But instead 0 and 1 there should be female and male
and
it would be great if it shows not the number but the percentage
just like this
female - 58 %
male - 42 %

Difficult for me, but perhaps easy for you

Thanks

Matthias
gpaed.de

Last edited by:

Matthias70: Apr 28, 2008, 2:50 PM
Subject Author Views Date
Thread Show user gender Matthias70 6144 Apr 28, 2008, 2:48 PM
Post Re: [Matthias70] Show user gender
Andy 5897 Apr 28, 2008, 11:27 PM
Thread Re: [Matthias70] Show user gender
Andy 5898 Apr 29, 2008, 1:50 AM
Thread Re: [Andy] Show user gender
Wychwood 5886 Apr 29, 2008, 2:26 AM
Thread Re: [Wychwood] Show user gender
Andy 5907 Apr 29, 2008, 2:27 AM
Thread Re: [Andy] Show user gender
Wychwood 5918 Apr 29, 2008, 2:30 AM
Thread Re: [Wychwood] Show user gender
Andy 5886 Apr 29, 2008, 2:35 AM
Post Re: [Andy] Show user gender
Wychwood 5866 Apr 29, 2008, 2:44 AM
Thread Re: [Andy] Show user gender
Matthias70 5882 Apr 29, 2008, 8:23 AM
Thread Re: [Matthias70] Show user gender
Andy 5863 Apr 29, 2008, 10:12 AM
Post Re: [Andy] Show user gender
Matthias70 5880 Apr 29, 2008, 10:23 AM