Jump to content

Excluding Weekends in a dropdown box of dates


ShopMAster

Recommended Posts

Hello Coders,

 

  I'm having some trouble with this and maybe you can help me out.  I'm displaying the last 15 days in a dropdown list but I can't figure out how to exclude the weekends (Sat and Sun) from that list.  I'm kind of new to this whole PHP stuff so any help would be very much appreciated:

 

  Here is what I have

 

 

<form name="form" id="form">
       <select name="jumpMenu" id="jumpMenu">
       <option value="#">Select Day</option>
       <?php 
   $m= date("m");
       $de= date("d");
       $y= date("Y");
        for($i=0; $i<=15; $i++){
        echo "<option value=daytest.php?dateselect=" . date('mdy',mktime(0,0,0,$m,($de-$i),$y)) . "&day=" . date('F d, Y',mktime(0,0,0,$m,($de-$i),$y)) . "'>" . date('D, F d, Y',mktime(0,0,0,$m,($de-$i),$y)) . "</option>";

} 
?>
       </select>
       <input type="button" name="go_button" id= "go_button" value="Go" onclick="MM_jumpMenuGo('jumpMenu','parent',0)" />
     </form>

 

Thanks for your guidance.

prolly easier to do in a while for this:

$i = 0;
$num_days = 0;
while( $num_days < 15 ){
        if(date('D',mktime(0,0,0,$m,($de-$i),$y)) != "Sat" && date('D',mktime(0,0,0,$m,($de-$i),$y)) != "Sun"){
echo "<option value=daytest.php?dateselect=" . date('mdy',mktime(0,0,0,$m,($de-$i),$y)) . "&day=" . date('F d, Y',mktime(0,0,0,$m,($de-$i),$y)) . "'>" . date('D, F d, Y',mktime(0,0,0,$m,($de-$i),$y)) . "</option>";
$num_days++;
}

$i++;
}

something like that.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.