Solved

remove selectbox options depending on current date

Posted on 2007-03-29
4
161 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now