Paul (moderator) had a mod at
http://www.gossamer-threads.com/...D%20-%20NewX;#168184 to produce a Top X list list which I modified slightly. Here is what he had
Code:
#!/usr/bin/perleval {
($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1");
($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1");
require "admin/links.cfg";
require "$db_lib_path/db_utils.pl";
require "$db_lib_path/links.def";
};
if ($@) {
print "Content-type: text/plain\n\n";
print $@;
exit;
}
&main;
sub main {
my @data = `tail -$max_new $db_links_name`;
my $i = 0;
print "Content-type: text/html\n\n";
print "<table>";
foreach (@data) {
$i++;
chomp;
split /\|/;
print qq|<tr><td>$i.</td><td><a href="$_[$db_url]">$_[$db_title]</a></td></tr>|;
}
print "</table>";
}
Then in links.cfg add a
new variable:
$max_new = X;
X being the number of
new links you want to show.
Then include the file into your page using SSI ...eg
<!--#exec cgi="/cgi
-bin/links/topx.cgi"-->
I renamed it list.cgi
Code:
#!/usr/bin/perleval {
($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1");
($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1");
require "/home/acct351/cgi-bin/links/admin/links.cfg";
require "$db_lib_path/db_utils.pl";
require "$db_lib_path/links.def";};
if ($@) {
print "Content-type: text/plain\n\n";
print $@;
exit;
}
&main;sub main {
my @data = `tail -999 $db_links_name`;
my $i = 0;
my $cat="";
my $rest="";
print "Content-type: text/html\n\n";
foreach (@data) {
$i++;
chomp;
split /\|/;
# $_[$db_desc] =~ s,\`\`,<br>,g; this also works
$_[$db_desc] =~ s,``,<br>,g;
$_[$db_category] =~ s,_, ,g;
($cat, $rest)= split(/\//,$_[$db_category]);
print qq|
<TR class="test" onmouseover="this.className='test2'" onmouseout="this.className='test'">
<TD width=15 ALIGN=RIGHT VALIGN=top><FONT class=f3>$i.</FONT></TD>
<TD width=100 VALIGN=top>
<A class=mLink HREF="
http://">Email</A></TD"]mailto:$_[$db_contact_email]">Email</A></TD>
<TD width=100 VALIGN=top><FONT class=f3>$_[$db_area]</FONT> </TD>
<TD width=400 VALIGN=top><FONT class=f3>$_[$db_desc]</FONT> </TD></TR>|;
}
}
Ignore all the reference to class, mouseovers/outs. I just added some stuff to allow sorting by clicking on the columns headings and to highlight the active row.
OK, don't laugh. I'm sure it is not very good but it works. and I don't use it often.
Paul gets all the credit for this. I just added a little html stuff.
I'm not sure about the "tail" thing. But I guess it starts at the last record and works backward. I have don't have that many records so the
- 999 works OK. Somehow it starts at the first record and then goes to the last record.
here is what the table looks like
Code:
<TABLE id=table2 class=tblborder1 BORDER=1 BGCOLOR="#CDD3F8"
CELLSPACING=0 CELLPADDING=6 WIDTH="96%">
<tbody>
<TR>
<TH width=15 ALIGN=RIGHT VALIGN=top>Line#</TH>
<TH width=100 VALIGN=top>Link</TH>
<TH width=100 VALIGN=top>State</TH>
<TH width=100 VALIGN=top>Category</TH>
<TH width=100 VALIGN=top>Email</TH>
<TH width=100 VALIGN=top>Area</TH>
<TH width=400 VALIGN=top>Desc</TH>
</TR>
<!--#exec cgi="/cgi-bin/links/list.cgi"-->
</TABLE>
Once again my table is for sorting. you can use just a plain table
Not sure if this is what you want but here is what I did. And it is very slow to bring up
Gene "The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."