0

We have a button that runs reports based on a date selects' values. I want to create a similar button next to this one to run the same report but for today only, how do I define the date values for that button based on the existing code?

     <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>

I understand I don't need the Select values here, but is that all I'd need to do?

PHP Noob!

4

1 回答 1

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');
}
?>
于 2013-07-11T12:24:44.720 回答