如何创建一个按钮,仅为今天运行报告(以及更多设置日期)

时间:2013-07-11 12:14:28

标签: php html

我们有一个按钮,根据日期选择'运行报告。值。我想在此旁边创建一个类似的按钮来运行相同的报告,但仅限今天,如何根据现有代码定义该按钮的日期值?

     <tr bgcolor="#efefef" onMouseOver="this.bgColor='#ddddff';" onMouseOut="this.bgColor='#efefef';">
<td width="19%">Start Date</td>
<td width="81%"><select name="sd" style="width:100px;">
        <? 
        $current_day = date('d');
        $current_month = date('m');
        $current_year = date('Y');
        $cur = 1;
         while (31 >= $cur) {
         echo "<option value=\"".sprintf("%02d", $cur)."\" ".(($cur == $current_day)?'selected':'').">".sprintf("%02d", $cur)."</option>\n";
         $cur++;
         } ?>
      </select> &nbsp; <select name="sm" style="width:150px;">
        <? $cur = 1;
         while (12 >= $cur) {
         echo "<option value=\"".sprintf("%02d", $cur)."\" ".(($cur ==    ($current_month-1))?'selected':'').">".date("F", strtotime("2006-".sprintf("%02d",    $cur)."-01"))."</option>\n";
         $cur++;
         } ?>
      </select>  
      &nbsp; <select name="sy" style="width:100px;">
        <? $cur = 1;
        $curyear = date("Y");
         while (10 >= $cur) {
         echo "<option value=\"$curyear\">$curyear</option>\n";
         $curyear--;
         $cur++;
         } ?>
      </select> </td>
  </tr>
     <tr bgcolor="#efefef" onMouseOver="this.bgColor='#ddddff';" onMouseOut="this.bgColor='#efefef';">
<td>End Date</td>
<td><select name="ed" style="width:100px;">
        <? $cur = 1;
         while (31 >= $cur) {
         echo "<option value=\"".sprintf("%02d", $cur)."\" ".(($cur == $current_day)?'selected':'').">".sprintf("%02d", $cur)."</option>\n";
         $cur++;
         } ?>
      </select> &nbsp; <select name="em" style="width:150px;">
        <? $cur = 1;
         while (12 >= $cur) {
         echo "<option value=\"".sprintf("%02d", $cur)."\" ".(($cur == ($current_month))?'selected':'').">".date("F", strtotime("2006-".sprintf("%02d", $cur)."-01"))."</option>\n";
         $cur++;
         } ?>
      </select>  
      &nbsp; <select name="ey" style="width:100px;">
        <? $cur = 1;
        $curyear = date("Y");
         while (10 >= $cur) {
         echo "<option value=\"$curyear\">$curyear</option>\n";
         $curyear--;
         $cur++;
         } ?>
      </select> </td>
  </tr>
     <tr bgcolor="#efefef" onMouseOver="this.bgColor='#ddddff';" onMouseOut="this.bgColor='#efefef';">
       <td>&nbsp;</td>
       <td><input type="submit" name="button" id="button" value="Get Report"></td>
     </tr>
<tr>
  </table></form>

我知道我不需要这里的选择值,但这是我需要做的吗?

PHP Noob!

1 个答案:

答案 0 :(得分:2)

<?php
if(isset($_REQUEST['submit']))
{
// put your code on selected date here..
}
else if(isset($_REQUEST['submit'])) // another submit button name
{
$current_day = date('d');
$current_month = date('m');
$current_year = date('Y');
}
?>