Arrow

Adding custom columms in table | Peter's Sports League Standings | Forum

Back to the sports standings script page

Please consider registering
guest

Log In

Lost password?
Advanced Search

— Forum Scope —

  

— Match —

   

— Forum Options —

   

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
Adding custom columms in table
May 26, 2009
2:59 pm
Ph
Guest

I want to add another stat into the table. Is it easy enough to do? im not asking for it to be done for me... but guidelines on how to do it ( what files to modify etc)

I also want this stat to be able to give a bonus point.

help appreciated very much.

May 28, 2009
1:32 am
Peter
Admin
Forum Posts: 841
Offline

First, you'll have to edit the sportsdb_wins and sportsdb_teams tables to add the new column. Then, edit admin_files/addscore.php, admin_files/addscoreyes.php, admin_files/editscore.php, and admin_files/updatescore.php to handle the editing of that new column. Points and the display of the column are handled in standings.php.

June 2, 2009
2:47 pm
ph
Guest

great, thanks mate

I'll give it a go. and let you know how it goes. ;)

June 2, 2009
6:36 pm
ph
Guest

hi peter,

The new stat is a snooker break over 50 for a snooker league called halfs.

Ive added the new stat into the database into sportsdb_teams called halfs and sportsdb_wins called homehalf and awayhalf. Ive also managed to get the form fields to save the value for the home team or away team.

Ive also managed to set a if statement for if the value is over 50 but lower than 100 then add 1 to the value in sportsdb_teams and if its over 100 add 2 to the value.

Then i edited standings.php to display the value that was in the halfs column in sportsdb_teams. This displays correctly and i also added the sort option for it.

Now i may sound a bit dumb here. (or its getting late) But i cant seem to work out how i add the value of halfs to amount of points.

June 3, 2009
1:54 am
Peter
Admin
Forum Posts: 841
Offline

Hi,

In standings.php, there are two MySQL queries that involve a line calculating the points:

(teamwins * $points_win + teamforfeits * $points_forfeit + teamties * $points_tie) AS points

Depending on how you award the points, you could tack on something like " + snookerbreak * 1" in those parentheses.

June 3, 2009
6:37 am
ph
Guest

ah... i see.. it must of been late :P

thanks a lot.

My next task now is...

Say i have two new columns. they both work the same way. But i only wanted to display the column if there was a value higher than 0.

I would just use If value >=1 then display column and results etc etc...

Just wondering if i had 2 conferences running but the 2nd conference doesn't require this stat. So all the games played in the 2nd conference will have the stat's value at 0 (as default). Hopefully, the table wont show this column for that conference or will it because in conference 1 there is a value over 0?

Starting to get into stuff now that is a bit advanced for my knowledge and it is starting to confuse my brain at times.

You been great help mate, once i have it all perfect etc etc... i'll make sure there is a link back. plus will show you the final thing to see what mods ive done etc.

June 6, 2009
3:57 pm
Peter
Admin
Forum Posts: 841
Offline

The queries run on individual conferences, so you should be OK there. That being said, if you're testing based on the fact that *any* team had a value for that column greater than zero, you'd have to write another query to test for that anyway... and that query would have to limit the results to teams in a particular conference.

June 9, 2009
6:55 am
ph
Guest

I got around the problem by simplifying the added bonus system. So didnt need to do any of the querys (thankfully).

Like said above i would show what i have done. There is a link to your blog on the index page ( i will copy it over to other pages ).

Few things ive added, Renamed conferences and seasons to be more appropiate for my use, Changed teams to players. Changed master teams to game types. Player history is now game type history. Added statistics to show how many leagues, results players etc. ( Working on displaying the last 5 results entered, last 5 players added etc, being a pain though).

You may also notice a few of your other scripts on there! [Image Can Not Be Found]

The CSS needs fixing to cope with IE. So best way is to view the site in Firefox or google chrome. Also have a bug with the admin login at the moment. Seem to get errors when i display the login fields on the site. Works fine if secure.php is on its own.

Just like to say a big thanks peter, Its been a good learning curve for me by following your code. (I hadn’t touched php before i came across this)

http://funkyleagues.com

June 24, 2009
2:06 am
Peter
Admin
Forum Posts: 841
Offline

Looks good! There shouldn't be any problems with placing the login form elsewhere. You just need to send it to update.php and post one field "username" and one field "pass".