1

我正在尝试显示特定员工的休假历史记录,但是当我选择特定月份时,例如:我选择显示一月,而不是显示一月的历史记录,它显示了今年的所有历史记录..那里我的代码有什么问题吗?下面是我的代码:

<?php
    echo 'View the application history by :<select name="date">
            <option value="january" selected="selected">January</option>
            <option value="february" >February</option>
            <option value="march">March</option>
            <option value="april">April</option>
            <option value="may">May</option>
            <option value="june">June</option>
            <option value="july">July</option>
            <option value="august">August</option>
            <option value="september">September</option>
            <option value="october">October</option>
            <option value="november">November</option>
            <option value="december">December</option>';
    echo'</select>';
            $value = 'value';
            if($value=='january')
            {
                 $check_user=mysql_query("select*from employee e, `leave` l where e.emp_id = l.emp_id and l.Emp_ID='".$aid."' and Date_Apply >='2013-01-01' and Date_Apply<'2013-01-31'"); 
            }
            else if($value=='february')
            {
                 $check_user=mysql_query("select*from employee e, `leave` l where e.emp_id = l.emp_id and l.Emp_ID='".$aid."' and Date_Apply >='2013-02-01' and Date_Apply<'2013-02-28'");
            }
                else if($value=='march')
            {
                 $check_user=mysql_query("select*from employee e, `leave` l where e.emp_id = l.emp_id and l.Emp_ID='".$aid."' and Date_Apply >='2013-03-01' and Date_Apply<'2013-03-31'");
            }
                else if($value=='april')
            {
                 $check_user=mysql_query("select*from employee e, `leave` l where e.emp_id = l.emp_id and l.Emp_ID='".$aid."' and Date_Apply >='2013-04-01' and Date_Apply<'2013-04-30'");
            }
                else if($value=='may')
            {
                 $check_user=mysql_query("select*from employee e, `leave` l where e.emp_id = l.emp_id and l.Emp_ID='".$aid."' and Date_Apply >='2013-05-01' and Date_Apply<'2013-05-31'");
            }
                else if($value=='june')
            {
                 $check_user=mysql_query("select*from employee e, `leave` l where e.emp_id = l.emp_id and l.Emp_ID='".$aid."' and Date_Apply >='2013-06-01' and Date_Apply<'2013-06-30'");
            }
                else if($value=='july')
            {
                 $check_user=mysql_query("select*from employee e, `leave` l where e.emp_id = l.emp_id and l.Emp_ID='".$aid."' and Date_Apply >='2013-07-01' and Date_Apply<'2013-07-31'");
            }
                else if($value=='august')
            {
                 $check_user=mysql_query("select*from employee e, `leave` l where e.emp_id = l.emp_id and l.Emp_ID='".$aid."' and Date_Apply >='2013-08-01' and Date_Apply<'2013-08-31'");
            }
                else if($value=='september')
            {
                 $check_user=mysql_query("select*from employee e, `leave` l where e.emp_id = l.emp_id and l.Emp_ID='".$aid."' and Date_Apply >='2013-09-01' and Date_Apply<'2013-09-30'");
            }
                else if($value=='october')
            {
                 $check_user=mysql_query("select*from employee e, `leave` l where e.emp_id = l.emp_id and l.Emp_ID='".$aid."' and Date_Apply >='2013-10-01' and Date_Apply<'2013-10-31'");
            }
                else if($value=='november')
            {
                 $check_user=mysql_query("select*from employee e, `leave` l where e.emp_id = l.emp_id and l.Emp_ID='".$aid."' and Date_Apply >='2013-11-01' and Date_Apply<'2013-11-30'");
            }
                else if($value=='december')
            {
                 $check_user=mysql_query("select*from employee e, `leave` l where e.emp_id = l.emp_id and l.Emp_ID='".$aid."' and Date_Apply >='2013-12-01' and Date_Apply<'2013-12-31'");
            }

        echo "<table border='1'>";

        echo "<tr>";
        echo "<th>Leave No</th>";
        echo "<th>Leave Start</th>";
        echo "<th>Leave End</th>";
        echo "<th>Date Apply</th>";
        echo "<th>Duration</th>";
        echo "<th>Leave Type</th>";
        echo "<th>Leave Reason</th>";
        echo "<th>Status</th>";


    $counter = 0;
    while($rows = mysql_fetch_assoc($check_user))
    {
        echo"<tr>";
        echo"<td>" . $rows['Leave_ID'] . "</td>";
        echo"<td>" . $rows['Leave_Start'] . "</td>";
        echo"<td>" . $rows['Leave_End'] . "</td>";
        echo"<td>" . $rows['Date_Apply'] . "</td>";
        echo"<td>" . $rows['Duration'] . "</td>";
        echo"<td>" . $rows['Leave_Type'] . "</td>";
        echo"<td>" . $rows['Leave_Reason'] . "</td>";
        echo"<td>" . $rows['Status'] . "</td>";
        $counter++;
    }
    echo "</table>";
?>
4

1 回答 1

2

是的。您将 $value 的值设置为“值”。然后检查该变量是否包含月份的名称。那是不可能的。另外:如果您从选择框中读取月份的名称(并将其放入名为 $date 的变量中),月份的名称将位于名为 $date 的变量中。除此之外,选择框不会做任何事情,因为它需要在表单标签内。(并提交按钮或其他东西来提交该表单..然后将其读出(通过使用GET)并将其放入$date变量中..虽然我会使用不同的名称,以确保名称是唯一的.. .)

于 2013-09-02T15:13:21.267 回答