473,386 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

comparing months not working

hi. i have the following code:

$now=getdate();
$currMonth = $now["month"];
$currYear = $now["year"];
$currDay = $now["mday"];
for($i=1; $i<=12; $i++){
$month = date("F",mktime(0, 0, 0, $i));
if ($month == $currMonth)
echo "<option value='".$month."' selected='selected'>".$month."</
option>";
else
echo "<option value='".$month."'>".$month."</option>";
}

all i want to do is dynamically output a selection box containing all
the months of the year, and have the selection default to the current
month. however, i'm not sure why it's not working. please help.
thanks
Jul 12 '08 #1
3 1265
whatchamakeofit schrieb:
hi. i have the following code:

$now=getdate();
$currMonth = $now["month"];
$currYear = $now["year"];
$currDay = $now["mday"];
for($i=1; $i<=12; $i++){
$month = date("F",mktime(0, 0, 0, $i));
if ($month == $currMonth)
echo "<option value='".$month."' selected='selected'>".$month."</
option>";
else
echo "<option value='".$month."'>".$month."</option>";
}

all i want to do is dynamically output a selection box containing all
the months of the year, and have the selection default to the current
month. however, i'm not sure why it's not working. please help.
thanks
Why not using $now['mon']; ? 1-12
And later if ($i == $now['mon']) ?
Jul 12 '08 #2
thx, that works!

but, i'm still wondering, why wouldn't my previous code work?

On Jul 12, 10:14 am, Olaf Schinkel <tr...@schinkel.tvwrote:
whatchamakeofit schrieb:
hi. i have the following code:
$now=getdate();
$currMonth = $now["month"];
$currYear = $now["year"];
$currDay = $now["mday"];
for($i=1; $i<=12; $i++){
$month = date("F",mktime(0, 0, 0, $i));
if ($month == $currMonth)
echo "<option value='".$month."' selected='selected'>".$month."</
option>";
else
echo "<option value='".$month."'>".$month."</option>";
}
all i want to do is dynamically output a selection box containing all
the months of the year, and have the selection default to the current
month. however, i'm not sure why it's not working. please help.
thanks

Why not using $now['mon']; ? 1-12
And later if ($i == $now['mon']) ?
Jul 12 '08 #3
whatchamakeofit wrote:
hi. i have the following code:

$now=getdate();
$currMonth = $now["month"];
$currYear = $now["year"];
$currDay = $now["mday"];
for($i=1; $i<=12; $i++){
$month = date("F",mktime(0, 0, 0, $i));
if ($month == $currMonth)
echo "<option value='".$month."' selected='selected'>".$month."</
option>";
else
echo "<option value='".$month."'>".$month."</option>";
}

all i want to do is dynamically output a selection box containing all
the months of the year, and have the selection default to the current
month. however, i'm not sure why it's not working. please help.
thanks
Works for me.

--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Nothing he's got he really needs
Twenty first century schizoid man.
***********************************

Jul 12 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

45
by: Market Mutant | last post by:
I just wonder job selections, job openings and salary level of PHP programer or Perl programmer comparing to Java programmers. Is Java programmer's salary has a minimal of 60K in US? Are there...
3
by: Job Lot | last post by:
How can compare two dates in terms of months. i.e. 01/08/2004 = 10/08/2004 05/08/2004 < 01/08/2005 thanx
3
by: JazeMail | last post by:
I've only ever used built in SQL Server tools but have been looking at log tools. I looked at Log Explorer 4.02 from lumigent.com and was very impressed with what I saw. The prices tag per instance...
3
by: Robert Dell | last post by:
I have a problem comparing strings in an order form i'm writing. I want to give a running total at the bottom of the page and it appears to be working except it doesn't compare correctly (it...
1
by: Lisa | last post by:
Hello! I need help to organize the working time spent by each employee on projects. I have many projects going on, staring at different dates, and each employee can work on 0/N projects, for #...
5
by: Rajat Tandon | last post by:
Hello Everybody, Please guide me so that I can fulfill this challenging assisnment ... I have been asked to "Restructure a Windows application" from scratch in 2 months. The existing...
4
by: Working_Girl | last post by:
Hi, I have a database with insurance clients and their dependents (spouses and children). We had a problem in the past with the twins and some of them have been entered with one month...
1
by: gderosa | last post by:
Hey everyone...I need to create a job which occurs once monthly that is based on a stored procedure that contains as a rough example: CREATE PROCEDURE CompareDate @CurrentDate datetime AS ...
2
by: bus007 | last post by:
I want to input months through the combo box and display data from a table that matches the particular month in ms access. Please give me an idea how to do it??
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.