These codes are for creating a separate page in the DBMAN system that will list the number of records in a certain field within the database.
1) In your
db.cgi file, add these codes to the list of elsif statments in the
sub main routine:
Code:
elsif ($in{'browse_cat'}) { if ($per_view) { &html_browse_cat; } else { &html_unauth; } }
2) In your
html.pl file, create a new sub-routine towards the bottom of the file. Name this sub-routine,
sub html_browse_cat:
Code:
sub html_browse_cat {
# --------------------------------------------------------
# Browse Academic Areas
for ($i = 0; $i <= $#db_cols; $i++) {
if ($db_cols[$i] eq "
FieldName") {
$fieldnum = $i; $found = 1;
last;
}
}
if (!$found) {
&cgierr("No Area field defined");
}
open (DB, "<$db_file_name") or &cgierr("unable to open $db_file_name. Reason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
next if /^#/;
next if /^\s*$/;
$line = $_;
chomp ($line);
@fields = &split_decode ($line);
if (!(grep $_ eq $fields[$fieldnum], @selectfields)) {
push (@selectfields, $fields[$fieldnum]);
}
++$count{$fields[$fieldnum]};
}
close DB;
&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: Browse Categories</title>
</head>
<body bgcolor="#FFFFFF">
|; &html_top_header; print qq|
<center>
<table bgcolor="#FFFFFF" cellpadding=2 cellspacing=0 width=600 align=center valign=top>
<tr><td>
<$font_title>
<b><A HREF="$db_script_link_url">$html_title</a> : Browse Categories</b>
</font>
<p>
<$font>
INSERT TEXT
<p>
|;
foreach $field (sort @selectfields) {
if ($sfield eq "") {
print qq| |;
}
if ($sfield = &urlencode($field)) {
print qq|<$font><a href="$db_script_link_url&view_records=1&ID=*&Area=$sfield">
$field</a>:</font> <$smfont>(<font color="ff0000">$count{$field}</font> )</font><BR>|;
}
}
&html_footer;
print qq|
</td></tr>
</table>
|; &html_bottom_footer; print qq|
</center>
</body>
</html>
|;
}
Replace the
FieldName with the field name in your
default.cfg file that you want to obtain a listing from. Also, in the link for the this mod, you may need to additional attributes, such as
so and
sb. Where it states INSERT TEXT, you will have to put your own text.
3) Then in your
sub html_home routine, add the following link:
Code:
<A HREF="$db_script_link_url&browse_cat=1">Browse Category</a>
Hope this makes sense and works for ya.
Regards,
------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
[This message has been edited by Eliot (edited September 10, 1999).]