AaronP Posted April 29, 2010 Share Posted April 29, 2010 Hi all, I'm more of a designer than a coder but I'm dabbling in some of the back end code for our website. The result I am trying to achieve is to create a drop down menu with a set of 14 dates calculated from the current date. To give more of an idea of what I am trying to achieve I will briefly explain the outline of the over all form. We are taking bookings for an event. The event is starting on Tuesday 11/5/2010 and will run every Tuesday there on. People who register can jump in at any week they wish. So what I need is something that will create a list of 14 weekly Tuesday dates from the current date. Allowing of course for this current week which won't have a session (starting 11/5/2010) I have found some code which might be useful and is working except it obviously counts from the current date and changes as the current date changes. <p align="left"><strong>What date would you like so start?<br /> <select name="start_date" style="width:215px;margin-top:4px"> <option value="">Select Date<option> <?php for ($i=1;$i<=13;$i++) { $strDate = date("D jS M Y",strtotime("+$i week")); echo "<option value=\"$strDate\">$strDate</option>"; }?> </strong> </p> Would appreciate your wisdom and guidance Cheers Aaron Link to comment https://forums.phpfreaks.com/topic/200133-dynamic-drop-down-menu/ Share on other sites More sharing options...
litebearer Posted April 29, 2010 Share Posted April 29, 2010 Perhaps... $startdate = "2010-11-05"; for ($i=1;$i<=13;$i++){ $newdate1 = date('D jS M Y', (strtotime(date("Y-m-d", strtotime($startdate)) . " +$i week"))) ?> <option value="<? echo $newdate1;?>"><?PHP echo $newdate1; ?></option><br><?PHP } Just a thought. Link to comment https://forums.phpfreaks.com/topic/200133-dynamic-drop-down-menu/#findComment-1050467 Share on other sites More sharing options...
AaronP Posted April 29, 2010 Author Share Posted April 29, 2010 Thank you so much litebearer , With a couple of minor changes it is now working perfectly. Cheers. For those who are interested the final code looked like this: <p align="left"><strong>What date would you like so start?<br /> <select name="start_date" style="width:215px;margin-top:4px"> <option value="">Select Date<option> <?php $startdate = "4-05-2010"; for ($i=1;$i<=13;$i++){ $newdate1 = date('D jS M Y', (strtotime(date("d-m-Y", strtotime($startdate)) . " +$i week"))) ?> <option value="<? echo $newdate1;?>"><?php echo $newdate1; ?></option><br><? }?> </strong> </p> Thanks again Link to comment https://forums.phpfreaks.com/topic/200133-dynamic-drop-down-menu/#findComment-1050475 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.