Hello Pugdog,
I found your post add was curious if you could re-write the sub for me so that I could show the top5 links by hits.
Here is your sub:
Code:
sub top5 {
# -----------------------------------------------
# Returns a list of the top5 searched terms.
#
my $in = new CGI;
my $search = new Links::DBSQL $LINKS{admin_root_path} . "/defs/Search_Log.def";
# Let's get a list of the top 5 terms ordered by number of times someone
# has searched on them.
my $results = $search->query ( { Term => '*', sb => 'Count', so => 'DESC', mh => 5 } );
my $output = '';
my $term_q;
if ($search->hits) {
foreach my $term (@{$results}) {
$term = $search->array_to_hash($term);
$term_q = $in->escape($term->{Term});
$output .= qq~ <LI><a href="$LINKS{db_cgi_url}/search.cgi?query=$term_q">${$term}{Term}</a>
~;
}
}
else {
$output = "Sorry no one has searched for anything yet.";
}
return $output;
}
I would be very grateful.