Page 1 of 1

Transactions & Team/League Leaders?

Posted: Thu Sep 17, 2015 8:42 am
by Bmoney0313
How's everyone outputting team transactions and team/league leaders?

I'm trying to build a PHP site using the SQLite database and I haven't found a good way to query the database to pull team transactions. I've gotten it to the point where it will out put TRADE : From $TeamName to Team2 : Player (OV). I've seen many sites just show the player/picks/money rather than just the line from the TeamLog table. Also it seems like with the SQLite database the TeamLog and LeagueLog only show the current days output? So if I'm trying to pull constant info from there it would be wiped away after each sim day?

Also I've had no luck being able to pull team/league leaders. I know I can use the ORDER BY command to hopefully get the top say Goal scorer but then how do I limit how many results I get back to say 10 rows (players)?

Once again, any help would be greatly appreciated.

Thanks,
Brandyn

Re: Transactions & Team/League Leaders?

Posted: Thu Sep 17, 2015 9:04 am
by Foo
je te donne une source pour t'aider dans tes démarches de défrichage. Pour tout ce qui concerne les requêtes à ta base de donnée (ce que tu places dans ton SQL pour aller chercher tes données) va lire ici: http://www.w3schools.com/php/php_mysql_select_limit.asp tu vas y trouver des exemples faciles pour tout ce qui concerne les requêtes mysql ou tu peux toujours taper dans google mysql limit ou peu importe ce que tu cherches.

Pour le PHP, cEst à dire le code qui va afficher ces données que tu es allé récupérer le manuel complet est là: https://secure.php.net/manual/fr/

encore là, tu peux faire la même chose et taper sur google PHP et ce que tu veux, il y a plein d'exemples de fonctions et autres que tu peux utiliser et transposer pour un site de hockey, la base demeure toujours la même!

bonne lecture!

Re: Transactions & Team/League Leaders?

Posted: Thu Sep 17, 2015 9:11 am
by Bmoney0313
Not sure if it matters or not, but I'm actually trying to do this all without having to setup a SQL database rather just using the SQLite database. The LIMIT function seems to work. I'll start incorporating this and see what I get. I've tried Googling SQL commands but most of them don't seem to work with SQLite databases but this one does.

Any input on the Transaction part?

(Thank you Google Translator)

Thanks,
Brandyn

Re: Transactions & Team/League Leaders?

Posted: Thu Sep 17, 2015 12:23 pm
by Bmoney0313
I'm also trying to figure out how I would take this array ($PlayerNameQuery = $db->query("SELECT Name FROM PlayerInfo WHERE TeamName = '$TeamName'"); while ($row3 = $PlayerNameQuery ->fetchArray())) which gets the player name based on the team name and compare it to the PlayerProStat table to get Goals/Assist/Points/etc.?

Nevermind...I got this part.

Re: Transactions & Team/League Leaders?

Posted: Thu Sep 17, 2015 1:03 pm
by Bmoney0313
It's too bad the PlayerProStat table doesn't have TeamNumber or TeamName as a column that would have made this much easier. Trying to get the roster from PlayerInfo based on TeamName or TeamNumber then taking that to PlayerProStat is a pain. I was able to pull back data now but I can't figure out how to pull back the top 5 based on the stat. I've tried ORDER BY G DESC but that's not working. It's just outputting the first 5 (LIMIT 5 is set) players from the team in the order they appear in the PlayerInfo table.

Re: Transactions & Team/League Leaders?

Posted: Thu Sep 17, 2015 7:51 pm
by SimonT
I think the query to get a limit number of result by order of Poiint is this :

SELECT Number, Name, P FROM PlayerProStat Order BY P DESC LIMIT 10

Re: Transactions & Team/League Leaders?

Posted: Thu Sep 17, 2015 8:23 pm
by Bmoney0313
The problem is querying PlayerInfo for TeamNumber/Name then using that array against PlayerProStat. I'm just not sure how to do that and limit the array to say 5 results (players).

Re: Transactions & Team/League Leaders?

Posted: Thu Sep 17, 2015 11:04 pm
by SimonT
You want the Team Leader?

Re: Transactions & Team/League Leaders?

Posted: Thu Sep 17, 2015 11:20 pm
by SimonT
Try this

SELECT PlayerInfo.Number, PlayerInfo.Name, PlayerInfo.Team, PlayerProStat.G, PlayerProStat.A, PlayerProStat.P FROM PlayerInfo INNER JOIN PlayerProStat ON PlayerInfo.Number = PlayerProStat.Number WHERE PlayerInfo.Team=2 Order BY P DESC LIMIT 10

Re: Transactions & Team/League Leaders?

Posted: Fri Sep 18, 2015 7:26 am
by Bmoney0313
That works perfectly! I had no idea you could query multiple tables in one statement by doing TableName.Column. Thanks for the info Simon!