pavankat Posted March 18, 2012 Share Posted March 18, 2012 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/259167-why-does-it-show-jan-when-i-select-nov-or-dec/ Share on other sites More sharing options...
requinix Posted March 18, 2012 Share Posted March 18, 2012 Your "maybe this will work" is causing the problem. $form_month is a string, not an array, and when you [] a string you get one of its characters... Quote Link to comment https://forums.phpfreaks.com/topic/259167-why-does-it-show-jan-when-i-select-nov-or-dec/#findComment-1328627 Share on other sites More sharing options...
pavankat Posted March 18, 2012 Author Share Posted March 18, 2012 omg dude you rock thank you soooo much! it's working! it's working! Quote Link to comment https://forums.phpfreaks.com/topic/259167-why-does-it-show-jan-when-i-select-nov-or-dec/#findComment-1328642 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.