I'm making one and I am trying to show an x number of reviews on the detailed pages for each link. I want to show the latest ones though. I can easily do it showing the first 2 but I used the Lastlink mod and I can't get it to work. I can see why but don't know how to fix it.
In sub detailed_view I have
$review = &opinions($rec{'ID'});
so that each time nph-build.cgi calls it for each Id it will call sub opinions, which looks like this
my $id = shift;
my $x = 2;
my (@lines, $link, @tmp, %tmp);
open (D, "<$db_opinions_name") or &cgierr("unable to open database:$db_opinions_name.\nReason: $!");
@lines = <D>;
close D;
A: for ($i = $#lines; $i >= $#lines - $x + 1; $i--) {
chomp $lines[$i];
@tmp = &split_op_decode ($lines[$i]);
%tmp = &array_to_op_hash (0, @tmp);
$link .= &site_html_opinions_link (%tmp) if ($tmp[$db_op_pid] == $id);
}
return $link;
}see so I have it set to show 2 reviews per ID. In my review db, I have the id to the link that the review is for stored as $db_op_pid. I check it against $id. That part works but when $x is set at 2 it will only print two for the first detailed page. When I set it to 4 (there are only three reviews for the first and second links), it prints 3 for the first and 1 for the second. So it's obviously not resetting or anything. Does anyone have a suggestion for better code? I was thinking of just starting the loop over.
Lavon Russell
LookHard Mods
lavon@lh.links247.net
In sub detailed_view I have
$review = &opinions($rec{'ID'});
so that each time nph-build.cgi calls it for each Id it will call sub opinions, which looks like this
Code:
sub opinions { my $id = shift;
my $x = 2;
my (@lines, $link, @tmp, %tmp);
open (D, "<$db_opinions_name") or &cgierr("unable to open database:$db_opinions_name.\nReason: $!");
@lines = <D>;
close D;
A: for ($i = $#lines; $i >= $#lines - $x + 1; $i--) {
chomp $lines[$i];
@tmp = &split_op_decode ($lines[$i]);
%tmp = &array_to_op_hash (0, @tmp);
$link .= &site_html_opinions_link (%tmp) if ($tmp[$db_op_pid] == $id);
}
return $link;
}
Lavon Russell
LookHard Mods
lavon@lh.links247.net