Gossamer Forum
Quote Reply
Total hits
hello

is there a tag or so that will show the total hits that the whole directory have recieved in a given time?
may be a global.. tag or so..!
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] Total hits In reply to
Hi,

Add a global:

total_hits =>
Code:
sub {
my ($total) = $DB->table('Links')->select(['SUM(Hits)'])->fetchrow_array;
return $total;
}

and then use <%total_hits%> in your template.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Total hits In reply to
thank you
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [Alex] Total hits In reply to
Alex,

sub {
my ($total) = $DB->table('Links')->select(['SUM(Hits)'])->fetchrow_array;
return $total;
}

How to sum for a special value?

For example a column in Links table called colour.
How to sum for the value BLUE ?

Michael


--
Michael Skaide

http://www.cycle24.de

Quote Reply
Re: [Michael Skaide] Total hits In reply to
Hi,

Do you mean a SUM or a COUNT? Do you want the number of rows that have Color=BLUE? If so, that would be:

sub {
my $total = $DB->table('Links')->count ( { Colour => 'BLUE' } );
return $total;
}

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Total hits In reply to
Thank you Alex,

it works fine and is easy to set.

How to count for 2 values?

For example colour=blue AND size=medium

Michael

--
Michael Skaide

http://www.cycle24.de

Quote Reply
Re: [Michael Skaide] Total hits In reply to
I'd guess exactly the same way

sub {
my $total = $DB->table('Links')->count ( { Colour => 'BLUE', Size => 'medium' } );
return $total;
}

Last edited by:

PaulW: Nov 17, 2001, 12:48 PM
Quote Reply
Re: [Michael Skaide] Total hits In reply to
Hi,

That would be:

sub {
my $total = $DB->table('Links')->count ( { Colour => 'BLUE', Size => 'Medium' } );
return $total;
}

If you needed it to be OR'd, you'd have to use a GT::SQL::Condition:

sub {
my $condtion = GT::SQL::Condition->new( ['Colour', '=', 'Blue'], ['Size', '=', 'Medium'] );
$condition->bool ('OR');
my $total = $DB->table('Links')->count ( $condition );
return $total;
}

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Total hits In reply to
Great,

that let me include some interesting statistics!

Michael

--
Michael Skaide

http://www.cycle24.de

Quote Reply
Re: [Alex] Total hits In reply to
Alex,

One more question on this. How would you wrap this into a .pl file that can be called through a SSI from any other html page? (not generated by LinksSQL)

Safe swoops
Sangiro
Quote Reply
Re: [Alex] Total hits In reply to
Another stats question....

How do I count the number of unique categories at a certain depth in your hierarchy? I.E My categories are generally laid out as follows: /region/country/state/

There are instances of regions without countries and in some cases countries without states. I want to display the number of unique countries only. What would the global look like?

Any help appreciated.

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] Total hits In reply to
How do I make a sub printing the number of hits (clicks) each day, 7 days back in time?

Kjetil
..........................
Kjetil Palmquist
www.svanger.com
Quote Reply
Re: [sangiro] Total hits In reply to
Quote:
How do I count the number of unique categories at a certain depth in your hierarchy?


Try my directory depth plugin. It will give you stats on the depth of your categories.

http://www.gossamer-threads.com/...orum.cgi?post=196792


http://www.iuni.com/...tware/web/index.html
Links Plugins
Quote Reply
Re: [Ian] Total hits In reply to
This is a great global. thanks.

I'm using to SUM and COUNT columns in my installation. Currently it gives totals for the whole database. How would I alter it to show by category. So at the Home page (Parent Category) it gives the totals for all. But if I drill down into another category it just gives me the totals within that category?

thanks...