ShopMAster Posted March 17, 2010 Share Posted March 17, 2010 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. Quote Link to comment Share on other sites More sharing options...
schilly Posted March 17, 2010 Share Posted March 17, 2010 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. Quote Link to comment Share on other sites More sharing options...
ShopMAster Posted March 17, 2010 Author Share Posted March 17, 2010 schilly, thank you from the bottom of my heart. It worked like a charm. You da man! - Shop Quote Link to comment Share on other sites More sharing options...
schilly Posted March 17, 2010 Share Posted March 17, 2010 =) np. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.