Jump to content

Recommended Posts

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

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 :D

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.