Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Re: [Matthias70] Global: List where the users come from?

Quote Reply
Re: [Matthias70] Global: List where the users come from? In reply to
Hi,

This should do it. It won't sort them by the amount of users per city, but it does get all the "unique" cities, and the number of users in them.

Code:
sub {

use lib '/path/to/community/private/lib';

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

my $sth = $NEWDB->table('comm_users')->select( ['DISTINCT(prof_city)'] ) || die $GT::SQL::error;

my @loop;
while (my $hit = $sth->fetchrow_hashref) {
if (length($hit->{prof_city}) < 1) { next; }
my $tmp;
$tmp->{City} = $hit->{prof_city};
$tmp->{count} = $NEWDB->table('comm_users')->count( { prof_city => $tmp->{City} } );
push @loop, $tmp;
}

return { city_loop_count => \@loop }

}

Call with:

Code:
<%global_name%>
<%loop city_loop_count%>
<%City%> total- <%count%> <br />
<%endloop%>

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Subject Author Views Date
Thread; hot thread Global: List where the users come from? Matthias70 7811 Dec 23, 2007, 2:54 AM
Thread; hot thread Re: [Matthias70] Global: List where the users come from?
Andy 7676 Dec 23, 2007, 3:23 AM
Thread; hot thread Re: [Andy] Global: List where the users come from?
Matthias70 7661 Dec 23, 2007, 3:39 AM
Thread; hot thread Re: [Matthias70] Global: List where the users come from?
Andy 7675 Dec 23, 2007, 3:47 AM
Thread; hot thread Re: [Andy] Global: List where the users come from?
Matthias70 7716 Dec 23, 2007, 3:52 AM
Thread; hot thread Re: [Matthias70] Global: List where the users come from?
Andy 7698 Dec 23, 2007, 3:58 AM
Thread; hot thread Re: [Andy] Global: List where the users come from?
Matthias70 7709 Dec 23, 2007, 4:03 AM
Thread; hot thread Re: [Matthias70] Global: List where the users come from?
Andy 7643 Dec 23, 2007, 4:05 AM
Thread; hot thread Re: [Andy] Global: List where the users come from?
Matthias70 7778 Dec 23, 2007, 4:09 AM
Thread; hot thread Re: [Matthias70] Global: List where the users come from?
Andy 7700 Dec 23, 2007, 4:14 AM
Thread; hot thread Re: [Andy] Global: List where the users come from?
Matthias70 7701 Dec 23, 2007, 4:18 AM
Thread; hot thread Re: [Matthias70] Global: List where the users come from?
Andy 7687 Dec 23, 2007, 4:19 AM
Thread; hot thread Re: [Andy] Global: List where the users come from?
Matthias70 7667 Dec 23, 2007, 10:57 AM
Thread; hot thread Re: [Matthias70] Global: List where the users come from?
Matthias70 7696 Dec 25, 2007, 12:33 PM
Thread; hot thread Re: [Matthias70] Global: List where the users come from?
Andy 7655 Dec 26, 2007, 12:40 AM
Thread; hot thread Re: [Andy] Global: List where the users come from?
Matthias70 7575 Dec 29, 2007, 12:14 PM
Thread; hot thread Re: [Matthias70] Global: List where the users come from?
Andy 7594 Dec 29, 2007, 12:33 PM
Thread; hot thread Re: [Andy] Global: List where the users come from?
Matthias70 7611 Dec 31, 2007, 6:25 AM
Post; hot thread Re: [Matthias70] Global: List where the users come from?
Andy 7568 Dec 31, 2007, 6:30 AM
Thread; hot thread Re: [Andy] Global: List where the users come from?
Matthias70 7556 Mar 23, 2008, 6:57 AM
Thread; hot thread Re: [Matthias70] Global: List where the users come from?
Andy 7538 Mar 23, 2008, 7:30 AM
Post; hot thread Re: [Andy] Global: List where the users come from?
Matthias70 7569 Mar 23, 2008, 8:37 AM