Hi Andy,
I have this global to show the gender on my site
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 }
}
<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
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