
02-25-10, 03:19 PM
|
|
Newbie Coder
|
|
Join Date: Feb 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
Query Question
I have a table in an mySQL database that lists total points (see attached screen shot), by year with a column that shows total points.
The screen shot shows the results of a query against the database table, which is not the problem. I am looking for a query that will display the ranking for each player for each year, based on the display shown. To further clarify I would like a column after 2005 which is headed 2009 ranking that would show where in the ranking for 2009, Rick T's total would fall. I have been trying to figure this out for a few days, but quite frankly don't even know where to start, as a matter of fact I don't know if it is even possible.
|

02-26-10, 06:58 PM
|
|
Aspiring Coder
|
|
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
|
|
Post your code, it is do-able, but we need to know what you're working with the help you out.
|

02-27-10, 12:02 AM
|
|
Newbie Coder
|
|
Join Date: Feb 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Here is the code that I started working with after posting this request.
This code has generated the display noted in the attached screen dump, and it also has a bunch of error msgs above the display. The error msgs are as follows. This is but one line of many with the same error msg.
while(Array = mysql_fetch_array( Resource id #3 )) { ; while(Array = mysql_fetch_array( Resource id #3 )) { ; while(Array = mysql_fetch_array( Resource id #3 )) {
The display in the screen dump is how I want it to look, except that the column starting with Ranking 2009 should contain the ranking of players for that year, not the total points that it currently displays. I have a feeling that I don't have enough information in the table, but thought I would check. thanks in advance for your help.
|

02-27-10, 09:52 PM
|
|
Aspiring Coder
|
|
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
|
|
I don't have the database info, so I made a passing try at getting it right on the first go around. It will most likely need some tweaking, so post back if it doesn't go off to well on this try.
Last edited by Jcbones; 02-27-10 at 09:57 PM.
Reason: Shoulda at least checked syntax.
|

02-27-10, 11:50 PM
|
|
Newbie Coder
|
|
Join Date: Feb 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for your response Jcbones, I think we are getting close. I took the code you provided in the previous post, and other than entering the database and table names, I uploaded it the script to the following site:
Lifetime Stats to see the result. I am not adept enough to be able to figure it out, but there are some errors as noted in the display. For instance, there should be no entries in the 2010 Rank column, as there are no points in the 2010 column. In addition, there are duplicate numbers in some of the other Rank columns.
As an example, the content of the 2009 Rank column (first five places) should be: (the names are the names in the first column (name)
Fred B 6
Rick T 5
John K 11
Kevin B 7
David H 22
Etc
I hope this makes sense, and thanks again for your help on this.
|

03-01-10, 07:35 PM
|
|
Aspiring Coder
|
|
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
|
|
Sorry it took so long for me to get back with you, I never have enough time for my projects.
Are all of the total points, and the 05/10 points correct?
|

03-01-10, 08:35 PM
|
|
Aspiring Coder
|
|
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
|
|
Try this one. very slight modifications.
|

03-01-10, 09:49 PM
|
|
Newbie Coder
|
|
Join Date: Feb 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yes, I believe this last bit of code you sent works. I'm double checking to make sure that the numbers are the same, but at first glance they are. Thank you very much for your help.
Now to get greedy, would it be possible to link the headers so that when clicked on, they would be sorted? I would need the headings labeled 2010, 2009, etc sorted by tot points DESC and the headings labeled 2010 Rank, 2009 Rank, etc sorted by place ASC. That would be awesome.
|

03-02-10, 05:03 PM
|
|
Aspiring Coder
|
|
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
|
|
You could do this with javascript, and save server load. Or, just pass the sort in the url using the GET method.
|

03-02-10, 05:06 PM
|
|
Aspiring Coder
|
|
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|