Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Here is a new cgi for LAST TERMS

Quote Reply
Here is a new cgi for LAST TERMS
Hi,

I have asked some days ago for a script to display the last search terms for all users. Well, here is a code to copy and paste, it will also show the time and build a correct link:

Code:
#!/usr/bin/perl

print "Content-type: text/html\n\n";

use DBI;

$dbh = DBI->connect('DBI:mysql:database:localhost', 'name','pw') or die $DBI::errstr;

$SQL = <<"EOT";

select *
from Search_Log
order by Last_Hit DESC
limit 30

EOT

$cursor = $dbh->prepare($SQL);
$cursor->execute;

print "<TABLE>\n";

while ( @columns = $cursor->fetchrow ) {
$Term = $columns[0];
$Term =~ s/ /+/g;
$Uhrzeit = substr($columns[3],10);
print ( "<TR><TD>$Uhrzeit</TD><td>   </TD><TD><a href=\"http://www.yourdomain.de/cgi-bin/search.cgi?query=$Term\">$columns[0]</a></TD></TR>\n");
}

print "</TABLE>\n";

$cursor->finish;
$dbh->disconnect;

exit;

You can easily adapt it for other purposes, eg. list ot Top 100 search terms etc.

Greetings from Germany,
Danny


[This message has been edited by Danny22 (edited February 12, 2000).]