-6

请帮忙。我似乎无法让所有文件同时出现。我认为这是因为我的代码中的年份选项。就像年份选项必须至少选择一年才能起作用。我需要知道如何创建一个默认选项来显示所有年份的结果。例如 2007 - 2013 年的结果。

Search.php 代码

<?php
$rpdsad=$_POST['rpdsad'];
$type=$_POST['project'];
$year=$_POST['year'];
$section=$_POST['section'];
$adviser=$_POST['adviser'];
mysql_connect('localhost','root','');
mysql_select_db('saddb');

if($rpdsad=="sad"){
/*1 query search*/
    if (empty($year) && empty($section) && empty($adviser)){
        $query=mysql_query("SELECT * from sadt WHERE type='$type'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>SAD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['sadcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/
/*1 query search*/
    elseif(empty($type) && empty($section) && empty($adviser)){
        $query=mysql_query("SELECT * from sadt WHERE year='$year'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>SAD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['sadcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/
/*1 query search*/
    elseif(empty($type) && empty($year) && empty($adviser)){
        $query=mysql_query("SELECT * from sadt WHERE section='$section'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>SAD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['sadcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/
/*1 query search*/
    elseif(empty($type) && empty($year) && empty($section)){
        $query=mysql_query("SELECT * from sadt WHERE adviser='$adviser'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><tr class=\"sabt\"><td>SAD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['sadcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/

/*2 query search*/
    elseif(empty($type) && empty($year)){
        $query=mysql_query("SELECT * from sadt WHERE section='$section' and adviser='$adviser'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>SAD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['sadcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/

/*2 query search*/
    elseif(empty($type) && empty($section)){
        $query=mysql_query("SELECT * from sadt WHERE year='$year' and adviser='$adviser'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>SAD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['sadcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/

/*2 query search*/
    elseif(empty($type) && empty($adviser)){
        $query=mysql_query("SELECT * from sadt WHERE year='$year' and section='$section'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>SAD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['sadcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/

/*2 query search*/
    elseif(empty($year) && empty($section)){
        $query=mysql_query("SELECT * from sadt WHERE type='$type' and adviser='$adviser'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>SAD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['sadcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/

/*2 query search*/
    elseif(empty($year) && empty($adviser)){
        $query=mysql_query("SELECT * from sadt WHERE type='$type' and section='$section'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>SAD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['sadcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/

/*2 query search*/
    elseif(empty($section) && empty($adviser)){
        $query=mysql_query("SELECT * from sadt WHERE type='$type' and year='$year'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>SAD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['sadcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/

/*3 query search*/
    elseif(empty($type)){
        $query=mysql_query("SELECT * from sadt WHERE section='$section' and year='$year' and adviser='$adviser'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>SAD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['sadcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/

/*3 query search*/
    elseif(empty($section)){
        $query=mysql_query("SELECT * from sadt WHERE type='$type' and year='$year' and adviser='$adviser'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>SAD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['sadcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/

/*3 query search*/
    elseif(empty($year)){
        $query=mysql_query("SELECT * from sadt WHERE type='$type' and section='$section' and adviser='$adviser'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>SAD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['sadcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/

/*3 query search*/
    elseif(empty($adviser)){
        $query=mysql_query("SELECT * from sadt WHERE type='$type' and section='$section' and year='$year'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>SAD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['sadcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/

/*4 query search*/
    elseif(!empty($adviser) && !empty($type) && !empty($section) && !empty($year)){
        $query=mysql_query("SELECT * from sadt WHERE type='$type' and section='$section' and year='$year' and adviser='$adviser'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>SAD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['sadcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/
}

/*rpd*/
elseif ($rpdsad=="rpd"){
/*1 query search*/
    if (empty($year) && empty($section) && empty($adviser)){
        $query=mysql_query("SELECT * from rpdt WHERE type='$type'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>RPD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['rpdcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/
/*1 query search*/
    elseif(empty($type) && empty($section) && empty($adviser)){
        $query=mysql_query("SELECT * from rpdt WHERE year='$year'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>RPD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['rpdcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/
/*1 query search*/
    elseif(empty($type) && empty($year) && empty($adviser)){
        $query=mysql_query("SELECT * from rpdt WHERE section='$section'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>RPD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['rpdcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/
/*1 query search*/
    elseif(empty($type) && empty($year) && empty($section)){
        $query=mysql_query("SELECT * from rpdt WHERE adviser='$adviser'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><tr class=\"sabt\"><td>RPD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['rpdcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/

/*2 query search*/
    elseif(empty($type) && empty($year)){
        $query=mysql_query("SELECT * from rpdt WHERE section='$section' and adviser='$adviser'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>RPD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['rpdcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/

/*2 query search*/
    elseif(empty($type) && empty($section)){
        $query=mysql_query("SELECT * from rpdt WHERE year='$year' and adviser='$adviser'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>RPD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['rpdcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/

/*2 query search*/
    elseif(empty($type) && empty($adviser)){
        $query=mysql_query("SELECT * from rpdt WHERE year='$year' and section='$section'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>RPD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['rpdcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/

/*2 query search*/
    elseif(empty($year) && empty($section)){
        $query=mysql_query("SELECT * from rpdt WHERE type='$type' and adviser='$adviser'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>RPD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['rpdcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/

/*2 query search*/
    elseif(empty($year) && empty($adviser)){
        $query=mysql_query("SELECT * from rpdt WHERE type='$type' and section='$section'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>RPD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['rpdcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/

/*2 query search*/
    elseif(empty($section) && empty($adviser)){
        $query=mysql_query("SELECT * from rpdt WHERE type='$type' and year='$year'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>RPD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['rpdcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/

/*3 query search*/
    elseif(empty($type)){
        $query=mysql_query("SELECT * from rpdt WHERE section='$section' and year='$year' and adviser='$adviser'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>RPD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['rpdcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/

/*3 query search*/
    elseif(empty($section)){
        $query=mysql_query("SELECT * from rpdt WHERE type='$type' and year='$year' and adviser='$adviser'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>RPD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['rpdcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/

/*3 query search*/
    elseif(empty($year)){
        $query=mysql_query("SELECT * from rpdt WHERE type='$type' and section='$section' and adviser='$adviser'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>RPD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['rpdcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/

/*3 query search*/
    elseif(empty($adviser)){
        $query=mysql_query("SELECT * from rpdt WHERE type='$type' and section='$section' and year='$year'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>RPD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['rpdcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }
/*end of section*/

/*4 query search*/
    elseif(!empty($adviser) && !empty($type) && !empty($section) && !empty($year)){
        $query=mysql_query("SELECT * from rpdt WHERE type='$type' and section='$section' and year='$year' and adviser='$adviser'");
        echo "<div align=center><table cellspacing=0 cellpadding=4 class=\"tabs\"><TR class=\"sabt\"><td>RPD Code</td><td>Year</td><td>Section</td><td>Title</td><td>Type of OLS</td><td>Adviser</td><td>Group Leader</td></tr>";
        while($row=mysql_fetch_array($query)){
            echo "<tr class=\"sbat\" valign=top><td nowrap>".$row['rpdcode']."</td><td>".$row['year']."</td><td>".$row['section']."</td><td style=\"text-align: left\">".$row['title']."</td><td>".$row['type']."</td><td>".$row['adviser']."</td><td>".$row['groups']."</td><td>";
        }
        echo "</table></div><BR>";
    }

/*end of section*/
}
?>

太感谢了!

4

1 回答 1

0

我发布了您需要的通用代码,您需要添加回显语句和查询。

<?php
$rpdsad=$_POST['rpdsad'];
$type=$_POST['project'];
$year=$_POST['year'];
$section=$_POST['section'];
$adviser=$_POST['adviser'];
mysql_connect('localhost','root','');
mysql_select_db('saddb');


/*
cases for "sad"
all empty
year
type
section
adviser
type year
type section
type adviser
year section
year adviser
section adviser
type year section
type year adviser
type adviser section
year adviser section
year section adviser type
*/

/* 
cases for "rpd"

all empty
year
section
year section

*/
if($rpdsad=="sad"){
    if(empty($type) && empty($year) && empty($section) && empty($adviser))
    {
        //all empty
    }
    elseif(!empty($type) && empty($year) && empty($section) && empty($adviser))
    {
        //type
    }
    elseif(!empty($type) && !empty($year) && empty($section) && empty($adviser))
    {
        //type and year
    }
    elseif(!empty($type) && empty($year) && !empty($section) && empty($adviser))
    {
        //type and section
    }
    elseif(!empty($type) && empty($year) && empty($section) && !empty($adviser))
    {
        //type and adviser
    }
    elseif(!empty($type) && !empty($year) && !empty($section) && empty($adviser))
    {
        //type, year and section
    }
    elseif(!empty($type) && !empty($year) && empty($section) && !empty($adviser))
    {
        //type, year and adviser
    }
    elseif(!empty($type) && empty($year) && !empty($section) && !empty($adviser))
    {
        //type, adviser and section
    }
    elseif(empty($type) && !empty($year) && empty($section) && empty($adviser))
    {
        //year
    }
    elseif(empty($type) && !empty($year) && !empty($section) && empty($adviser))
    {
        //year and section
    }
    elseif(empty($type) && !empty($year) && empty($section) && !empty($adviser))
    {
        //year and adviser
    }
    elseif(empty($type) && !empty($year) && !empty($section) && !empty($adviser))
    {
        //year, adviser and section
    }
    elseif(empty($type) && empty($year) && !empty($section) && empty($adviser))
    {
        //section
    }
    elseif(empty($type) && empty($year) && !empty($section) && !empty($adviser))
    {
        //section and adviser
    }
    elseif(empty($type) && empty($year) && empty($section) && !empty($adviser))
    {
        //adviser
    }
    else{
        //all fields 
    }
}
else{   //RPD
    if(empty($year) && empty($section))
    {
        //all empty
    }
    elseif(!empty($year) && empty($section))
    {
        //year
    }
    elseif(empty($year) && !empty($section))
    {
        //section
    }
    else{
        //all fields 
    }
}
?>

肯定有更好的方法来做到这一点......如果我想到它,我会更新解决方案。

您的 HTML 中也有一些语法错误,请使用 IDE 或在此处验证您的 HTML:w3c 验证器

于 2013-06-20T16:12:57.820 回答