Default Year in SELECT Dropdown

Hello Folks,

little easy one for ya. I have a basketball league that we just added a new schedule to. Our schedule.php file is not displaying the current year. Normally in HTML,. i just use the “selected” option in the OPTION field. However, this has some PHP scripts that im not too familiar with. How do I get the LATEST year to display. It’s in the list, but its still defaulting to last years’ schedule.

URL: http://www.phillygoyaball.com/pgbl/schedule.php

Here is the code:

<?php $site->design->printBefore( ); ?>
    <h1>Schedule</h1>
    <center>
    <form action="schedule.php" method="get">
    Select Year:&nbsp;&nbsp;&nbsp;
    <select name="year">
    <?php
    $site->db->Open( );
    $sql="select distinct year from game ORDER BY year";
    $rslt = $site->db->Execute($sql);
      while ( $teams = mysql_fetch_array( $rslt ) )
      {
     if ($teams['year'] == $year){
     echo "<option selected value='".$teams['year']."'>". $teams['year']."</option>";
     }else{
     echo "<option value='".$teams['year']."'>". $teams['year']."</option>";
     }
     }
    ?>
   

Thank you so much!

Sponsor our Newsletter | Privacy Policy | Terms of Service