Solved

remove selectbox options depending on current date

Posted on 2007-03-29
4
168 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 143

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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

695 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