amylou Posted July 31, 2007 Share Posted July 31, 2007 hi all, this code works but it does not show the months like January, Febuary, March ect instead it shows January, March,March, May, May, July, July,August,October,October,Dec,Dec. Any ideas on how to fix it below is the code that i used: <?php function getmonth($m=0) { return (($m==0 ) ? date('F') : date('F', mktime(0,0,0,$m))); } ?> <td><select size='1' name='monthRequest'> <?php $todaysDate = date("Y-m-d",time()); list($year, $month, $day) = split('[-]', $todaysDate); for( $i = 1; $i <= 12; $i++ ) { $myMonth = getmonth( $i ); echo "<option value='$i'"; if( $i == $month ) { echo "selected"; } echo ">$myMonth</option>"; } ?> </select> </td> <td><select size='1' name='dayRequest'> <?php for( $i = 1; $i <= 31; $i++ ) { echo "<option value='$i'"; if( $i == $day ) { echo "selected"; } echo ">$i</option>"; } ?> </select></td> <td><select size='1' name='yearRequest'> <?php for( $i = 2007; $i <= 2007; $i++ ) { echo "<option value='$i'"; if( $i == $year ) { echo "selected"; } echo ">$i</option>"; } ?> </select></td></tr> thank you for your help Link to comment https://forums.phpfreaks.com/topic/62730-solved-need-help-with-the-following-code/ Share on other sites More sharing options...
Grodo Posted July 31, 2007 Share Posted July 31, 2007 That is because you use 3 of the same varibles in your for loop Use different varibles try that see if it works Link to comment https://forums.phpfreaks.com/topic/62730-solved-need-help-with-the-following-code/#findComment-312272 Share on other sites More sharing options...
Barand Posted July 31, 2007 Share Posted July 31, 2007 Using mktime like that is going to default to the current day of the current month So you get Feb 31 , which is March 3 etc. Use mktime (0,0,0, $m, 1, $date('Y')) PS> or be patient and wait until tomorrow. It will work again then Link to comment https://forums.phpfreaks.com/topic/62730-solved-need-help-with-the-following-code/#findComment-312276 Share on other sites More sharing options...
amylou Posted August 1, 2007 Author Share Posted August 1, 2007 thank you for your helpl when i opened the program today it was working properly, i tried changing the code but it did not work. thanks again. Link to comment https://forums.phpfreaks.com/topic/62730-solved-need-help-with-the-following-code/#findComment-313196 Share on other sites More sharing options...
Barand Posted August 1, 2007 Share Posted August 1, 2007 OOOPS! remove $ from $date Use "mktime (0,0,0, $m, 1, date('Y'))" (If you leave it it will fail again on August 31) Link to comment https://forums.phpfreaks.com/topic/62730-solved-need-help-with-the-following-code/#findComment-313199 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.