Here is some code from the top10 plugin that should be easy enough for you to modify...
use strict;
use Links qw/$IN $DB $TPL $CFG/;
use lib ''; top10();
sub top10 {
# -------------------------------------------------------------------
# This subroutine will get called whenever the user clicks
# on 'Top10' in the admin menu. Remember, you need to print
# your own content-type headers, you should use
#
my $FONT = 'font face="Tahoma,Arial,Helvetica" size="2"';
my $db = $DB->table('SearchLog'); my $output = qq~<B>Your current Top10 Queries:</b><BR><BR>
<table border=1 cellpadding=0 cellspacing=0><tr><td>
<table border=0 width=500>
<tr><td><$FONT>URL:</font></td>
</tr>
~;
my $search_db =
$DB->table('SearchLog'); $search_db->select_options ('ORDER BY HitCount DESC', 'LIMIT 10'); my $sth = $search_db->select;
while (my $hit = $sth->fetchrow_hashref) {
my $escaped = $IN->escape ($hit->{Term}); $output .= qq!
<tr><td>
$hit->{Term}</font></td>
</tr>
!;
}
$output .= "</table></td></tr></table>";
print $IN->header();
print qq~
<p><$FONT>$output</font></p>
~;
}
You would just need to change the table names and variables and this:
$search_db->select_options ('ORDER BY HitCount DESC', 'LIMIT 10');
...to reflect your requirements.
Also add the path to your admin directory at the top like..
use lib '/PATH/TO/ADMIN';
The red parts are the bits you will need to modify.
Paul Wilson.
new -
http://www.wiredon.net