08-24-2010, 06:10 PM | #1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Morgado's Favorite Forum Fascist
Join Date: Oct 2000
Location: Greensboro, NC
|
PING: php people
So I'm running a couple of queries to determine the percentage of his team's total offense that a player was responsible for. Here's that portion.
Code:
So I've got $pct[playerid][year] as an array. The problem is coming in sorting and displaying it. Here's what I have, and it's wrong. Code:
Two issues. 1. I want to sort on percentage. It's not doing it. 2. Here are the results of the code.
What am I doing wrong? (And no lectures about doing this in one query. I'm thinking two is going to be just easier, plus I'd really like to improve my multi-dimensional array skills, and this will help.)
__________________
The media don't understand the kinds of problems and pressures 54 million come wit'! Last edited by Ben E Lou : 08-24-2010 at 07:28 PM. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
08-24-2010, 06:11 PM | #2 |
Morgado's Favorite Forum Fascist
Join Date: Oct 2000
Location: Greensboro, NC
|
Heh. It's removing some of my table tags from the code, but I'm sure the problem is in the foreach statements and the array sort function.
__________________
The media don't understand the kinds of problems and pressures 54 million come wit'! |
08-24-2010, 06:17 PM | #3 |
Death Herald
Join Date: Nov 2000
Location: Le stelle la notte sono grandi e luminose nel cuore profondo del Texas
|
Don't you have to use 'usort' in there somewhere?
__________________
Thinkin' of a master plan 'Cuz ain't nuthin' but sweat inside my hand So I dig into my pocket, all my money is spent So I dig deeper but still comin' up with lint |
08-24-2010, 06:21 PM | #4 |
Death Herald
Join Date: Nov 2000
Location: Le stelle la notte sono grandi e luminose nel cuore profondo del Texas
|
or, try moving the array_multisort after the foreach commands
edit: yeah, I think this is it, because array_multisort needs an array of columns, not rows.
__________________
Thinkin' of a master plan 'Cuz ain't nuthin' but sweat inside my hand So I dig into my pocket, all my money is spent So I dig deeper but still comin' up with lint Last edited by cartman : 08-24-2010 at 06:32 PM. |
08-24-2010, 06:39 PM | #5 |
Morgado's Favorite Forum Fascist
Join Date: Oct 2000
Location: Greensboro, NC
|
That's not it. If I move the statement, it only gives me one row. If I completely remove that statement, I get the same output. I've got something wrong in the syntax that's causing it to do...nothing.
__________________
The media don't understand the kinds of problems and pressures 54 million come wit'! |
08-24-2010, 06:43 PM | #6 |
Morgado's Favorite Forum Fascist
Join Date: Oct 2000
Location: Greensboro, NC
|
Ha. I figured out why playerid isn't showing up...
Code:
Hey, dummy! Player ID isn't gonna show up IF YOU DON'T HAVE IT IN THE QUERY!!!
__________________
The media don't understand the kinds of problems and pressures 54 million come wit'! Last edited by Ben E Lou : 08-24-2010 at 06:43 PM. |
08-24-2010, 06:43 PM | #7 |
Death Herald
Join Date: Nov 2000
Location: Le stelle la notte sono grandi e luminose nel cuore profondo del Texas
|
Here's a sample snippet I found that pointed me towards moving the array_multisort:
Code:
__________________
Thinkin' of a master plan 'Cuz ain't nuthin' but sweat inside my hand So I dig into my pocket, all my money is spent So I dig deeper but still comin' up with lint |
08-24-2010, 07:06 PM | #8 |
Morgado's Favorite Forum Fascist
Join Date: Oct 2000
Location: Greensboro, NC
|
I don't think that's it. Moving it around isn't helping. I'm not terribly good with arrays yet, so I'm not certain, though.
__________________
The media don't understand the kinds of problems and pressures 54 million come wit'! |
08-25-2010, 09:25 AM | #9 |
Pro Starter
Join Date: Oct 2005
Location: Washington, DC
|
If I find time today I'll try to play with this. But I don't use PHP enough to know the answer without trying it.
__________________
Sixteen Colors ANSI/ASCII Art Archive "...the better half of the Moores..." -cthomer5000 |
08-25-2010, 09:58 AM | #10 |
Head Coach
Join Date: Oct 2002
Location: Colorado Springs
|
Edit: Hang on, trying something.
Last edited by Coffee Warlord : 08-25-2010 at 10:01 AM. |
08-25-2010, 10:18 AM | #11 |
College Benchwarmer
Join Date: Apr 2008
Location: Sterling Heights, Mi
|
Sorry, I can't be much help. I avoid arrays and will go to great lengths to code without them. If you figure it out, please post it. I run into problems like this all the time. If I see the solution, it might help my own multi-dimensional array problems
|
08-25-2010, 10:35 AM | #12 | |
Pro Starter
Join Date: Oct 2005
Location: Washington, DC
|
Quote:
I have no idea how you can code while avoiding arrays!
__________________
Sixteen Colors ANSI/ASCII Art Archive "...the better half of the Moores..." -cthomer5000 |
|
08-25-2010, 10:51 AM | #13 |
College Benchwarmer
Join Date: Apr 2008
Location: Sterling Heights, Mi
|
Since I do not use arrays, I have no idea how you can code while using arrays. Seriously, I have a fantasy football website for my keeper league. I keep track of standings, stats, records, etc. I have spent a considerable amount of time to set up the databases and record input pages to work without arrays. It would have probably taken me a lot less time to just sit down one day and figure it out. Last edited by fantom1979 : 08-25-2010 at 10:52 AM. |
08-25-2010, 11:02 AM | #14 |
Head Coach
Join Date: Oct 2002
Location: Colorado Springs
|
I believe this'll do it.
Code:
Last edited by Coffee Warlord : 08-25-2010 at 11:04 AM. |
08-26-2010, 05:25 AM | #15 |
Morgado's Favorite Forum Fascist
Join Date: Oct 2000
Location: Greensboro, NC
|
Thanks for that, CW. I'll give it a try.
__________________
The media don't understand the kinds of problems and pressures 54 million come wit'! |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
|
|