Jump to content

[SOLVED] need help with the following code


amylou

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.