View Full Version : Ranking Dropdowns (non-duplicates)

09 Feb 2008, 04:17
What I'm trying to do is have the user rank from 1-25 (or something like that) a list of items. I don't want the numbers to be repeated, so there needs to be some kind of validation to where it removes or changes the selection if you pick/type a duplicate.

Are dropdowns the easiest way to go here? If so, i haven't found anywhere how to accomplish this. Can anybody point me in the right direction or give me some advice on how to accomplish this?

09 Feb 2008, 04:29
When I made a ranking system for a ladder system, I used this code.

$rank = 0 + ($perpage * $pagenumber);
while($clans = $db->query_read($clan_query))
// ...

I found this was the easiest way to keep a update ranking system without storing it in the database and updating every hour, day, etc.

Then when I wanted to get it for a individual clan, I used this code

$rankcount = $db->query_first("SELECT COUNT(column) AS 'count' FROM clans WHERE exp > $clanexp");

$rank = $rankcount['count']++;

09 Feb 2008, 04:34
Thanks for the quick reply. I'm however, looking to commit the value (eventually) to the database (and am using it on a form). My intention is to use it in the VBContest hack I created.

It is a pick 'em contest for sports. What I want to have is "confidence" ranking where you just don't pick the winner of each game, you pick the winner and assign a confidence value (1-20). If you win, you get that value. If you lose, you get zero. Adds another dimension to the game.

If you do ESPN Bowl Pick 'Em -- it's just like that.

09 Feb 2008, 04:49
You can have a column in like your user table called confidence_points. This column will hold the points they have gain total. When a user goes to assign a confidence value, the game id(if are you wanting to use it or you can use a different way to tell games part) and the value is stored in a new table. When the game is finished/reported into system, the system will then find all the users that guess correct and add the points to the column confidence_points.

Then a query like this can determine who has the most points.

SELECT * FROM users ORDER BY confidence_points + 0 DESC LIMIT 30

There is still a lot to fill in the system but that should get you the basic ranking system.

Sorry I never played ESPN Bowl Pick 'Em but this my understanding of their system after a quick look through.

09 Feb 2008, 05:58
For example:

On the entry form, we list 20 games (Texas vs Texas A&M, etc). They pick a winner, then in another field, rank it in confidence 1-20.

I need a way to make sure they don't duplicate the ranking in more than one game. That's what I'm looking for. I don't want them to be able to put Texas A&M as 18 and Michigan as 18.

09 Feb 2008, 18:36
You can have a table like this.

CREATE TABLE `games` (
`gameid` int(10) NOT NULL auto_increment,
`week` mediumint(5) NOT NULL default '0',
`hometeam` varchar(255) NOT NULL default '',
`visitingteam` varchar(255) NOT NULL default ''
Then a table like this.

CREATE TABLE `confidence_choices` (
`gameid` int(10) NOT NULL auto_increment,
`userid` int(10) NOT NULL default '0',
`week` mediumint(5) NOT NULL default '0',
`confidence_points` mediumint(2) NOT NULL defaut '0'

Then when they send in their confidence points, you just run a query like this.

$check_confidence = $db->query_first("SELECT COUNT(gameid) AS 'count' FROM confidence_choices WHERE week = $week AND confidence_points = $confidece_point");

if($check_confidence['count'] == 0)
//User hasn't submit value
//User has submit value, show error message