i am trying to figure out how to sort on multiple fields so i can sort by category and list the records within each category in alphabetical order. i have read everything (i think!) at the FAQ site, but my db.cgi does not look like the mods.
Then in db.cgi sub query comment out this:
# $in{'so'} ? ($order = $in{'so'}) : ($order = "ASC");
# $in{'sb'} and ($sortby = "ORDER BY $in{'sb'} $order");
and add:
my $order;
for (1 .. 6) {
$in{"sb$_"} and ($order .= qq~$in{"sb$_"} $in{"so$_"},~);
}
chop $order;
$order ? ($sortby = "ORDER BY $order") : ($sortby = '');
i don't have the lines that the above says to comment out. the closest thing i can find is :
# Sort the array @hits in order if we are meant to sort.
if (exists $in{'sb'}) { # Sort hits on $in{'sb'} field.
my ($sort_order, $sort_func);
$in{'so'} ? ($sort_order = $in{'so'}) : ($sort_order = "ascend");
$sort_func = "$db_sort{$db_cols[$in{'sb'}]}_$sort_order";
foreach $hit (sort $sort_func (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit; $last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sortedhits, @hits[$first .. $last]);
}
@hits = @sortedhits;
}
is this the right place? how do i adjust the mod to fit? i'm assuming that the code at FAQ was written for an older version of dbman? thanks for any help!
Code:
Then in db.cgi sub query comment out this:
# $in{'so'} ? ($order = $in{'so'}) : ($order = "ASC");
# $in{'sb'} and ($sortby = "ORDER BY $in{'sb'} $order");
and add:
my $order;
for (1 .. 6) {
$in{"sb$_"} and ($order .= qq~$in{"sb$_"} $in{"so$_"},~);
}
chop $order;
$order ? ($sortby = "ORDER BY $order") : ($sortby = '');
i don't have the lines that the above says to comment out. the closest thing i can find is :
Code:
# Sort the array @hits in order if we are meant to sort.
if (exists $in{'sb'}) { # Sort hits on $in{'sb'} field.
my ($sort_order, $sort_func);
$in{'so'} ? ($sort_order = $in{'so'}) : ($sort_order = "ascend");
$sort_func = "$db_sort{$db_cols[$in{'sb'}]}_$sort_order";
foreach $hit (sort $sort_func (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit; $last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sortedhits, @hits[$first .. $last]);
}
@hits = @sortedhits;
}
is this the right place? how do i adjust the mod to fit? i'm assuming that the code at FAQ was written for an older version of dbman? thanks for any help!