PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
orbdrums
Forum Commoner
Posts: 82 Joined: Wed Sep 14, 2011 11:42 pm
Post
by orbdrums » Thu Aug 01, 2013 9:05 pm
I have the following code that worked great until today, August 1st, 2013. When I display the $v_month variable, it equals 08 but it selects January. If I hard code 08 in to the $v_month variable, it selects September. Any help would be appreciated.
Code: Select all
$v_month = substr(date("m/d/y"),0,2);
<select name="v_month" type="text" id="v_month">
<option value="01Jan"<? if($v_month==01){ echo 'selected'; } ?>>Jan</option>
<option value="02Feb"<? if($v_month==02){ echo 'selected'; } ?>>Feb</option>
<option value="03Mar"<? if($v_month==03){ echo 'selected'; } ?>>Mar</option>
<option value="04Apr"<? if($v_month==04){ echo 'selected'; } ?>>Apr</option>
<option value="05May"<? if($v_month==05){ echo 'selected'; } ?>>May</option>
<option value="06Jun"<? if($v_month==06){ echo 'selected'; } ?>>Jun</option>
<option value="07Jul"<? if($v_month==07){ echo 'selected'; } ?>>Jul</option>
<option value="08Aug"<? if($v_month==08){ echo 'selected'; } ?>>Aug</option>
<option value="09Sep"<? if($v_month==09){ echo 'selected'; } ?>>Sep</option>
<option value="10Oct"<? if($v_month==10){ echo 'selected'; } ?>>Oct</option>
<option value="11Nov"<? if($v_month==11){ echo 'selected'; } ?>>Nov</option>
<option value="12Dec"<? if($v_month==12){ echo 'selected'; } ?>>Dec</option>
</select>
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Thu Aug 01, 2013 9:21 pm
Leading zeros on numbers
mean octal , and 08 and 09 are invalid octal numbers. Remove the zeros.
And the way you get $v_month is more complicated than it needs to be. Guess you don't know how
date works?
orbdrums
Forum Commoner
Posts: 82 Joined: Wed Sep 14, 2011 11:42 pm
Post
by orbdrums » Thu Aug 01, 2013 9:30 pm
Well I don't know a lot but thanks for your help and the link. It worked great!!
Christopher
Site Administrator
Posts: 13596 Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US
Post
by Christopher » Fri Aug 02, 2013 2:22 pm
Code: Select all
<select name="v_month" type="text" id="v_month">
There is no
type="text" attribute for the <select> tag. It is probably ignored, but show be removed.
(#10850)