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

Grab link by hits and votes...

Quote Reply
Grab link by hits and votes...
Hi. I'm just wondering, how easy is it to grab the 'top' link (i.e with the most hits, and best ranking). I've had a look through LSQL to see how it does it, but I can't get my head around it Unsure

TIA.

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!
Quote Reply
Re: [Andy] Grab link by hits and votes... In reply to
Something like this? I'm not sure what you mean by 'top' as I don't think the link with the most hits is likely to also have the highest rating. If you mean two different links:

sub {
my ($output,$sth,$link);
my $search_db = $DB->table('Links');
$search_db->select_options ("ORDER BY Rating DESC, LIMIT 1");
$sth = $search_db->select ( {isValidated => 'Yes'});
while ($link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('link', $link);
}
return $output;
}

sub {
my ($output,$sth,$link);
my $search_db = $DB->table('Links');
$search_db->select_options ("ORDER BY Hits DESC, LIMIT 1");
$sth = $search_db->select ( {isValidated => 'Yes'});
while ($link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('link', $link);
}
return $output;
}
Quote Reply
Re: [afinlr] Grab link by hits and votes... In reply to
I'm thinking more like integrated into one sub/query. Thanks for the suggestion though.

Any ideas?

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!
Quote Reply
Re: [Andy] Grab link by hits and votes... In reply to
I'm still not sure I understand - do you want two links returned?
Quote Reply
Re: [afinlr] Grab link by hits and votes... In reply to
I need one link, based on the average between top hits and rating. Its pretty confusing :(

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!
Quote Reply
Re: [Andy] Grab link by hits and votes... In reply to
And still needs more explaining ... this is reminding me of my phd Crazy. If you want to use more than one variable to measure something it is not at all straightforward. What about if you take the link with the highest rating and if there is more than one, take the one with the most hits?

sub {
my ($output,$sth,$link);
my $search_db = $DB->table('Links');
$search_db->select_options ("ORDER BY Rating DESC Hits DESC, LIMIT 1");
$sth = $search_db->select ( {isValidated => 'Yes'});
while ($link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('link', $link);
}
return $output;
}

Last edited by:

afinlr: Jul 29, 2003, 2:04 PM
Quote Reply
Re: [Andy] Grab link by hits and votes... In reply to
Could it be something like this? I just found this when I was in the resources section.

http://www.gossamer-threads.com/...ces/jump.cgi?ID=2174
Quote Reply
Re: [SSmeredith] Grab link by hits and votes... In reply to
Unfortunately not. This is just averaging ratings from the reviews and the ratings which are hopefully measuring exactly the same thing. The number of hits and the ratings are not measuring the same thing or they would be proportional and you could just take an average. Many of the most popular links on my site are ones with the lowest ratings.