Arrow

Adding more years? | 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 more years?
October 2, 2010
8:51 pm
Jason
Guest

Currently the "Add New Game" form only displays 3 years to choose from. Is there a way to change it so that it shows more than 3 years (eg 2005 - 2011)? Thanks.

October 3, 2010
7:45 pm
Peter
Admin
Forum Posts: 841
Offline

In admin_files/add_score.php you'll see this code:

<select name="year[]">

You can hardcode the year options below that code or do some sort of foreach loop to output a certain number of years. Something similar would have to be done in admin_files/edit_score.php as well.

October 4, 2010
4:59 am
Jason
Guest

Hey Peter. Thanks for the quick reply.

I had tried hard-coding the years I needed before posting this question, but it seems as though the years are based off a Unix Timestamp. When I hard-coded 2005, 2006, 2007 and 2008 in, the years showed up as 2001 when viewed from the site /admin area.

October 4, 2010
10:34 pm
Peter
Admin
Forum Posts: 841
Offline

Followed up via e-mail. Will post results when we get them.

October 5, 2010
4:36 am
Jason
Guest

Thanks Peter. Email has been sent.

October 6, 2010
8:32 am
Peter
Admin
Forum Posts: 841
Offline

Here's the code for the expanded year dropdowns as given to Jason, although this forum strips the indents:

admin_files/add_score.php

<select name="year[]">
<?php
// Max year is this year + 1. Start year is 2000
$thisyear = date( 'Y' ) + 1;
for( $outputyear = 2000; $outputyear <= $thisyear; $outputyear++ )
{
print '<option value="' . $outputyear . '">' . $outputyear . '</option>';
}
?>
</select>

admin_files/edit_score.php

<select name="year">
<?php
// Max year is this year + 1. Start year is 2000
$thisyear = date( 'Y' ) + 1;
for( $outputyear = 2000; $outputyear <= $thisyear; $outputyear++ )
{
print '<option value="' . $outputyear . '"';
if( $year == $outputyear )
{
print ' selected="selected"';
}
print '>' . $outputyear . '</option>';
}
?>
</select>