Hi Peter,
Thanks a mil for a great piece of work. Thought I'd mention that I've been working to adapt your app for a Tennis league. Hope you don't mind. I'm making it publicly available and you still have the credit in the footer, etc.
I've been wanted to write my own tennis ladder app for quite a while, and more recently, develop the sports league standings script more, but other work has simply gotten in the way.
I'm trying to add a function to addscoreyes.php so that instead of outputing
"Successfully added the Score from Jan 12 2009, 12:00PM"
it outputs
"Successfully added: Joes beat Janes on Jan 12 2009, 12:00PM"
I can get the integer variables, but I'm having problem getting the team names (when I call output the $winner and $loser variables, i only get their integer values).
just to follow up, I ended up doing a simple mySQL query to put the TEAMIDs and TEAMNAMEs into an array and then pulling out the Team Names that were required.
I've also completed some Facebook Connect and Feed integration so I'll hopefully release a new version soon.
I'm working towards showing an icon beside a given team to indicate they are on a "hot" streak. This would be for winning at least 5 games in a row.
I think the general logic of the mySQL query would be to query each teamid individually to see if they have won their last 5 games.
I'm wondering if you think there would be a better, more efficient way? Seems like querying each team individually would increase server load a lot if there are many teams.
Maybe one possibility is to add a mySQL table for streaks, that would add up to 5 or revert to zero if there was a loss?
I think I just answered my own question. Not sure about the mySQL query tho.
in case anyone else needs the info, it was pretty simple:
i added a field in the mySQL sportsdb_teams called teamstreak.
Then i edited addscoreyes.php and deleteyes.php so that when the user updates, it runs teamstreak = teamstreak +1 or teamstreak = teamstreak -1 in the mySQL query.
Then in standings.php, you can do some if statements to say, for example, if teamstreak is equal or larger than 5, show icon (or something similar).
I’m glad you were able to get both of those things going.
For getting the team name from the ID, you can also see the get_team_name function in standings_functions.php.
As for the streak code, you would need to check the existing value in “teamstreak”, since in many league formats (like tennis) there is technically no “0? streak, and the reversal of a winning or losing streak is not just plus or minus one more.
Thanks for the info on the get_team_name function. That makes things much easier.
In terms of teamstreak. It's only meant to count winning streaks. So if the team wins a game, then it's teamstreak +1 (which adds up over time). But if a team losses a game, then teamstreak resets to 0. The teamstreak -1 is only used in deleteyes.php.
I see your point though, about a losing streak. If I was to implement that, it just be a matter of adding another field to the table, say "teamlosestreak" and doing a teamlosestreak +1 when a team loses a game. But then have teamlosesstreak reset to 0 if they were to win a game. This would work with deleteyes.php as well.