Solved

remove selectbox options depending on current date

Posted on 2007-03-29
4
163 Views
Last Modified: 2008-03-06
ive got a selectbox with all the week numbers starting with week 1 and finishing with week 52.

what i need to do is remove all the week numbers after a certain date in each month.  The certain date is the 3rd of each month.

currently we are on week 13.  when it comes to april 3rd, all week numbers before this date should no longer be available to select.  when it comes to may 3rd, all week numbers before the may 3rd should no longer be available and so on...

my problem is, i have no idea where to start or code something that will do the above??
0
Comment
Question by:ellandrd
  • 3
4 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 18814997
can you show your loop that fills the selectbox right now?

in php, you have extensive functions to get date information:
http://php.net/datetime

so:
$date = getdate();
$date2 = mktime(0,0,0, $date["mon"], 3, $date["year"] )
$week = date("W", $date2);

while ($week <= 53)
{
   echo "<option value=\"$week\">$week</option>";
   $week++;
}

0
 
LVL 16

Author Comment

by:ellandrd
ID: 18815019
ok what ive tried to do was this:

1) get todays date
2) loop from todays date to the 31/12/2007
3) create selectbox with all weeknumbers between these dates

but it didnt work too good.  i will take a look at what you suggested...
0
 
LVL 16

Author Comment

by:ellandrd
ID: 18815032
BTW my loop is like this at the moment:

for($wk = 1; $wk < 53; $wk++)
{
      <option value="'.$wk.'">'.$wk.'</option>
}



0
 
LVL 16

Author Comment

by:ellandrd
ID: 18815091
thank you - got it working now
0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

822 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question