Jump to content

Recommended Posts

I'm going insane. whenever I select Oct, Nov, Dec from the drop down it doesn't show the corresponding month appropriately.

 

I do this in the code and it shows 10, 11 or 12 corresponding to oct, nov, dec but then it shows no month if it's october, january if it's november or december. Help me please.

 

echo '<br /><br /> form month var dump: ';

var_dump($form_month);

 

 

 


$time = time();
$actual_month = date('m', $time);
$actual_year = date('Y', $time);
$word_month = date('M', $time);
$word_year = date('Y', $time);

  if (isset($_POST['form_month']) && isset($_POST['form_year']) && !empty($_POST['form_month']) && !empty($_POST['form_year']) )
        {
	$form_month = $_POST['form_month']; //multidimensional array but it should have only one value in it at a time I think
	$form_year = $_POST['form_year'];

	echo '<br /><br /> form month var dump: ';
	var_dump($form_month);
	//echo '<br /><br />'. $form_month['1'];

	$insert_month = $form_month['0']; //maybe this will work
	$insert_year = $form_year;
}else{
	$insert_month = $actual_month;
	$insert_year = $actual_year;
}

// I don't know how to convert the number 01 to Jan - so i'm doing this:
$wtf_word_month = "";

switch ($insert_month) {
    case 1:
        $wtf_word_month = "Jan";
        break;
    case 2:
        $wtf_word_month = "Feb";
        break;
    case 3:
        $wtf_word_month = "Mar";
        break;
    case 4:
        $wtf_word_month = "Apr";
        break;
    case 5:
        $wtf_word_month = "May";
        break;
    case 6:
        $wtf_word_month = "June";
        break;
    case 7:
        $wtf_word_month = "July";
        break;
    case 8:
        $wtf_word_month = "Aug";
        break;
    case 9:
        $wtf_word_month = "Sep";
        break;
    case 10:
        $wtf_word_month = "Oct";
        break;
    case 11:
        $wtf_word_month = "Nov";
        break;
    case 12:
        $wtf_word_month = "Dec";
        break;
}


?>

<h2><?php echo $wtf_word_month ." ". $insert_year; ?></h2>

	<form id="form_month_changer" action="account-overview.php" method="POST">

	Choose a month: <select name="form_month">
	<option value="<?php echo '$insert_month'; ?>" ><?php echo $wtf_word_month; ?></option>
	<option value="1">Jan</option>
	<option value="2">Feb</option>
	<option value="3">Mar</option>
	<option value="4">Apr</option>
	<option value="5">May</option>
	<option value="6">June</option>
	<option value="7">July</option>
	<option value="8">Aug</option>
	<option value="9">Sept</option>
	<option value="10">Oct</option>
	<option value="11">Nov</option>
	<option value="12">Dec</option>
	</select>  
	       
	Choose a year <input type="text" name="form_year" maxlength="4" size="4" value="<?php echo $insert_year; ?>">
	<input type="submit" value="Show me the calendar">
	</form>
  
    <?php echo draw_calendar($insert_month,$insert_year); ?>

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.