Php 我的密码有问题吗?
我试图显示某个员工的休假历史记录,但当我选择某个月时,例如:我选择显示一月的历史记录,而不是显示一月的历史记录,它显示今年的所有历史记录。我的代码有什么问题吗?下面是我的代码:Php 我的密码有问题吗?,php,Php,我试图显示某个员工的休假历史记录,但当我选择某个月时,例如:我选择显示一月的历史记录,而不是显示一月的历史记录,它显示今年的所有历史记录。我的代码有什么问题吗?下面是我的代码: <?php echo 'View the application history by :<select name="date"> <option value="january" selected="selected">January</option&g
<?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>";
?>
是。将$value的值设置为“value”。然后检查该变量是否包含月份的名称。那是不可能的。另外:月份的名称将在名为$date的变量中。。。如果您从选择框中读取它(并将其放入名为$date的变量中)。除此之外,选择框不会做任何事情,因为它需要位于表单标记内部。(和submit按钮或其他东西来提交表单..然后读出它(使用GET)并将其放入$date变量..尽管我会使用不同的名称,以确保名称是唯一的..“我的代码有什么错误吗?”-这个问题最适合于,看到他没有得到期望的输出,他问他的代码有什么问题我的代码有什么问题吗?
有!它不可读,多个层混淆,使用了不推荐的数据库API,使用if/else代替switch,可能还有这个列表。我的经理可以节省很多钱获得免费的代码审查。谢谢,我很感激:)