|
|
![]() |
|
|
Top | #1 |
|
OSNN Senior Addict
Joined: May 2002
Location: Stoney Creek, ON, Canada
Posts: 820
Reputation: 500
Power: 135 |
question for the programmers.. i have a standings table. Games played, wins, losses, ties, goals against, goals for. i create points on the fly. so.... $pts = 3*$wins + $ties Is it possible to sort everything by $pts? Points should have been in the DB, but because we were running into problems when we were updating scores. any tips would be cool thanks |
|
|
|
|
|
Top | #2 |
|
Glaanies script monkey
Joined: February 2003
Location: Chicago
Posts: 2,725
Reputation: 1520
Power: 155 |
I think the easiest thing to do would be to create another column in your table that includes points. You could use a sorting algorithm, but that would be overly complicated, if you insert the points into the table, then you could use
$query = "SELECT * FROM '$standings' ORDER BY '$pts' DESC"; I used to keep a site up for my fantasy baseball since we do monthly stats, and I would store the total in there as a similar thing, ending - beginning, here is my insert.php: PHP Code:
PHP Code:
|
|
|
|
|
|
Top | #3 |
|
I'm sorry Hal...
Joined: January 2002
Location: England
Posts: 5,514
Reputation: 1210
Power: 194 |
try
Code:
Select *, ((wins+3)*ties) as points from standings order by points |
|
|
|
|
|
Top | #4 |
|
*
Joined: December 2001
Location: USA
Posts: 6,496
Reputation: 2808
Power: 220 |
Originally Posted by Khayman
I agree with this posting, except
it would have to be like Code:
select *, ((wins*3)+ties) as points from standings ORDER BY points DESC |
|
|
|
|
|
Top | #5 |
|
I'm sorry Hal...
Joined: January 2002
Location: England
Posts: 5,514
Reputation: 1210
Power: 194 |
Originally Posted by X-Istence
lol, i edited mine before i saw your post to the same thing
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| mp3 sorting by id3 tag | Abbadon2001 | Windows Desktop Systems | 7 | March 6th, 2005 7:10pm |
| [C++] sorting MASSIVE amounts of data | Rexy | Web Design & Coding | 9 | August 22nd, 2003 4:16am |
| spam sorting prog? | cky | Windows Desktop Systems | 3 | December 29th, 2002 8:40am |
| WMP Video Freeze, Folder Sorting | aidoru | Windows Desktop Systems | 3 | September 27th, 2002 3:00am |
| sorting favorites | bisher | Windows Desktop Systems | 1 | August 24th, 2002 3:48pm |