Hi guys, i need help with this..

here's the idea..
you need to input first a month and a year then display the years along with the active notams of each year based on the month and year entered..

if i entered 03/06
the output should be like this:

Series of '00

0011 0800 0899

Series of '05

0013 0504 0909

Series of '06

0014 0017 0018 0019 0022 0023 0029 0051
0057 0400 0608 0657 0980 0980 1088 1088
0226 0228 0229 0230 0232 0250 0251 0252


i was able to display the notam numbers accordingly..
the problem is..the succeeding years also display the active notam numbers of the previous years..i just need to output the notam numbers according to their year..

the years to be displayed are based on the lowest year on the database that has active notam numbers [here,the 'status' column should be '0']..and also on the month and year the user entered [it should be equal to or less than that]...
here's the code i used:

PHP Code:
<?
$month 
$_POST['month'];
$year $_POST['year'];
//for the query
$mod $year.$month ."31"

    
$qry9 "SELECT DISTINCT byear FROM bnotam WHERE status = 0 AND type <> 'C' AND dtg <= '$mod' AND byear <= '$year' ORDER BY byear ASC";
    
$result9 mysql_query($qry9);
    
//Check whether the query was successful or not
    
echo "<br>";
    
$nr9=0;
        while (
$row9 mysql_fetch_array($result9))
    {
        
$nr9++;
        echo 
"<pre>";
        echo 
"<table align='center' bgcolor='white' border='0' bordercolor='#003399' cellpadding='0' cellspacing='0' rules='groups' width='750'>";
        echo 
"<tr bordercolor='#003399' bgcolor='#FFFFFF'>"
         echo 
"<td width='750' height='50' colspan='13' nowrap='nowrap' align='left'>";
        echo 
"<b>Series of '".$row9[0]."</b>";
        echo 
"<br>";
        echo 
"<table align='justify' bgcolor='white' border='0' bordercolor='#003399' cellpadding='0' cellspacing='0' rules='groups' width='400'>";
        echo 
"<tr bordercolor='#003399' bgcolor='#FFFFFF'>"
         echo 
"<td width='400' height='50' colspan='13' nowrap='nowrap' align='justify'>";
        echo 
"<pre>";
        
//HERE GOES THE NOTAM NUMBERS
    
        //set the number of columns
                
$columns 13;
        
$qry10 "SELECT * FROM bnotam WHERE status = 0 AND type <> 'C' AND dtg <= '$mod' AND byear <= '$row9[0]' ORDER BY number ASC";
        
$result10 mysql_query($qry10);
        
        
$num_rows mysql_num_rows($result10);
    
  
echo 
"<TABLE BORDER=\"0\">\n";
for(
$i 0$i $num_rows$i++) {
    
$row10 mysql_fetch_array($result10);
    if(
$i $columns == 0) {
        
//if there is no remainder, we want to start a new row
        
echo "<TR>\n ";
        
    }
    echo 
"<TD>" $row10['number'] . "&nbsp;&nbsp;</TD>\n";
    if((
$i $columns) == ($columns 1) || ($i 1) == $num_rows) {
        
//if there is a remainder of 1, end the row
        //or if there is nothing left in our result set, end the row
        
echo "</TR>\n";
    }
    
    
}
echo 
"</TABLE>\n"

          echo 
"</pre>";
        echo 
"</td>";
        echo 
"</tr>";
        echo 
"</table>";
        echo 
"</td>";
        echo 
"</tr>";
        echo 
"</table>";
        }
?>
please help me with this..i think there's a problem with my array..