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