I already wrote codes for alphabetically listing awhile back. But here it goes again:
1) Add the following codes to the elsif statements in the
sub main routine in the
db.cgi file:
Code:
elsif ($in{'browse_cat'}) { if ($per_view) { &html_browse_cat; } else { &html_unauth; } }
2) Add the following codes to the top of a new sub-routine called
sub html_browse_cat before the
&html_print_headers; codes. This sub-routine can be a duplicate of
sub html_home.
Code:
for ($i = 0; $i <= $#db_cols; $i++) {
if ($db_cols[$i] eq "
FieldName") {
$fieldnum = $i; $found = 1;
last;
}
}
if (!$found) {
&cgierr("No
FieldName 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 ($fields[1] eq "Yes") {
@values = split (/\Q$db_delim\E/o, $fields[$fieldnum]);
foreach $value (@values) {
if (!(grep $_ eq $value, @selectfields)) {
push (@selectfields, $value);
}
++$count{$value};
}
}
}
close DB;
Replace
FieldName with the name of the field that you would like to alphabetically list.
Then in the middle of the HTML codes in the sub-routine where you want the list to appear, use the following codes:
Code:
|;
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=*&sb=0&so=ascend&
FieldName=$sfield">
$field</a>:</font> <$smfont>(<font color="ff0000">$count{$field}</font> )</font><BR>|;
}
}
print qq|
Change
FieldName to the name of the field that you are listing.
3) To add a link to this listing, use the following:
Code:
<A HREF="$db_script_link_url&browse_cat=1">Browse Categories</a>
BTW: About the MySQL, one of my clients has purchased the SQL version and I am using MySQL on my server. To be perfectly, it is a pain to upgrade and also most if not all the mods written for the Standard DBMAN version will
NOT work.
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