Gossamer Forum
Home : Products : DBMan : Customization :

Ranking System

Quote Reply
Ranking System
I would like to put numbers automatically in result when I sort.
So, I can use this as ranking system.

Is this possible? I searched this forum, top ten by rate was found,
but I would like to make ranking system by any sort.

Thank you in advance.
Quote Reply
Re: [haruchan] Ranking System In reply to
http://www.gossamer-threads.com/perl/gforum/gforum.cgi?post=5272;search_string=ranking;#5272

I found this code, but it works ONLY the first page.
If I go to the 2nd or more pages, it starts as number 1
instead of continuing of the first page.

Please someone help.
Quote Reply
Re: [haruchan] Ranking System In reply to
Quote:
I found this code, but it works ONLY the first page.
If I go to the 2nd or more pages, it starts as number 1
instead of continuing of the first page.


Are you sure? The line $rank = (($nh-1)*$mh)+1; is designed to take the page into account. Maybe I made a mistake. Try

$in{'mh'} ? ($mh = $in{'mh'}) : ($mh = $db_max_hits);
$rank = (($nh-1)*$mh)+1;


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] Ranking System In reply to
Thank you for the answer.
I figured out that I needed to add "$nh = $in{'nh'}" also.

Now, I have more question little bit related to this.
As result, is there any way to add like "This page displays from 1 to 10"?

I added this, but I cannot figure out the last part.
If the records are 54, it displays from 50 to 60 instead of 50 to 54.

$startnh = (($nh-1)*$mh)+1;
$endnh = (($nh-1)*$mh)+$mh;

If ($db_total_hits gt "1" && $db_total_hits le "9")
{
print "This page shows from $startnh to $db_total_hits.";
}
elseIf ($db_total_hits ge "10")
{
print "This page shows from $startnh to $endnh.";
}
else {print "";}

Thank you in advance.
Quote Reply
Re: [haruchan] Ranking System In reply to
Cool! :-)

The total number of hits returned from a search is held in the $db_total_hits variable. Try this--

after

$endnh = (($nh-1)*$mh)+$mh;

add

if ($endnh > $db_total_hits) { $endnh = $db_total_hits; }


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] Ranking System In reply to
Thank you for the answer.
Now, I have a problem when there is only one record on the last page.

In this way, it displays "This page displays From 101 To 101.".
Is that possible to display "This page displays 101 ." on the last page with only one record?
Quote Reply
Re: [haruchan] Ranking System In reply to
You can try this. Instead of

elseIf ($db_total_hits ge "10")
{
print "This page shows from $startnh to $endnh.";
}
else {print "";}


try

elseIf ($db_total_hits ge "10") {
if ($startnh == $endnh) { print "This page shows $startnh."; }
else { print "This page shows from $startnh to $endnh."; }
}
else {print "";}


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.