You're doing fine, Larry.
The %in hash (a hash is an array that uses names instead of numbers to access the individual parts -- %rec is also a hash) usually comes from the input from a form. Take a look at sub parse_form in db.cgi to see how the %in hash is built. The query subroutine uses the %in hash to do the searches and to know where it is in the list.
When you display the "long" record, all of the search parameters are already in the %in hash -- that's what it searched on to come up with the record. $in{'mh'} is the maximum number of hits on a page. When you go to the "long" record, this is set to 1, so that only one record shows up. $in{'nh'} isn't really the number of hits. It's the page number of the hits. With the "long" record display, since $in{'mh'} = 1, $in{'nh'} is equal to the record number. But if you go from page to page in the short display, you'll see that, if $in{'mh'} = 10, record 11 will be on the second page -- $in{'nh'} = 2. (Whew! Didja follow all of that?
)
What I have in mind is tricking the script into thinking it has received input from a form, by setting the $in{'mh'} and $in{'nh'} values by hand, bypassing sub parse_form and going straight to sub query. (It helps me to anthropomorphize the script.
)
So, after all that, what you would do in html_record_long is, after you print out your record and the stuff for the top of your other column,
Code:
|; # to close off your print statement
$in{'mh'} = 5;
$in{'nh'} = 1;
my ($status2,@hits2) = &query('view');
my ($numhits) = ($#hits2+1) / ($#db_cols+1);
$i = 1;
for (0 .. $numhits - 1) {
%rec2 = &array_to_hash($_, @hits);
$long_url = $ENV{'QUERY_STRING'};
$long_url =~ s/\&nh=\d+//;
$long_url =~ s/\&mh=\d+//;
$long_url = "$db_script_url?$long_url&nh=$i&mh=1";
print qq|<P>$rec2{'
Date'}<BR>
<a href="$long_url">$rec2{'
Title'}</a>
|;
++$i;
}
and then all the stuff you need at the end of your page.
If you want to get fancy and not have a link to the current page in your list use
Code:
print qq|<P>$rec2{'
Date'}<BR>|;
unless ($rec2{$db_key} eq $rec{$db_key}) {
print qq|
<a href="$long_url">$rec2{'
Title'}</a>
|;
}
else { print $rec2{'
Title'}; }
Clear as mud?
------------------
JPD