title: Php query to mysql database not giving desired results
body: <p>So I have a database table with months, the number value for the months and years. <strong>eg. June, 6, 2020</strong>.</p>
  
  <p>I have a select drop-down that dynamically populates based on the data from the table.</p>
  
  <p>The idea is, if the current month is June, the select dropdown should only be populated with the months of June to December.</p>
  
  <p>The issue I am having, which I don't undestand, is that on the page when I run the query, the drop down is only being populated with May to September. Whereas if I run the same query directly on the table in the database, I get the desired results.</p>
  
  <p>The query below:</p>
  
  <pre><code>    $yvalue = $_POST['years']; //assume this to be "2020";
      $curyear = date('Y');
      $curmonth = date('n'); // Lets also assume this to be "5";
  
      if ($yvalue==$curyear) {
  
      $query = "SELECT calmonthsID, months, value, years from calmonths WHERE years=? AND value&gt;=? ORDER BY calmonthsID ASC";
      $stmt = $connQlife-&gt;prepare($query);
      $stmt-&gt;bind_param('ss', $yvalue, $curmonth);
      $stmt-&gt;execute();
      $stmt-&gt;store_result();
      $stmt-&gt;bind_result($calmonthsID, $months, $value, $years);
  
      }else{
      $query = "SELECT calmonthsID, months, value, years from calmonths WHERE years=? ORDER BY calmonthsID ASC";
      $stmt = $connQlife-&gt;prepare($query);
      $stmt-&gt;bind_param('s', $yvalue);
      $stmt-&gt;execute();
      $stmt-&gt;store_result();
      $stmt-&gt;bind_result($calmonthsID, $months, $value, $years);
      }
  
      echo "&lt;option&gt;- Select Month -&lt;/option&gt;";   
  
      while($stmt-&gt;fetch()) {
          echo '&lt;option value='.$value.'&gt;'.$months.'&lt;/option&gt;'; 
      } $stmt-&gt;close();
  </code></pre>
  
  <p>When the above query runs on the page, the drop down is populated with months May to September. Omitting October to December.</p>
  
  <p>When I assumed <code>$curmonth = date('n');</code> to be <code>10</code> I get the drop down populated with months February to December. Omitting January.</p>
  
  <p>Again When I assumed <code>$curmonth = date('n');</code> to be <code>11</code> I get the drop down populated with months February to December. Omitting January and October.</p>
  
  <p>And when I assumed <code>12</code>, January, October  and November were missing.</p>
  
  <p>But running all these queries directly in the database gave the desired results. So I am puzzled as to what is wrong or what is happening when running the queries in Php.</p>
  
  <p>This is the database data:</p>
  
  <pre><code>calmonthsID  months      value     years
  1            January      1        2020
  2            Febuary      2        2020
  3            March        3        2020
  4            April        4        2020
  5            May          5        2020
  6            June         6        2020
  7            July         7        2020
  8            August       8        2020
  9            September    9        2020
  10           October      10       2020
  11           November     11       2020
  12           December     12       2020
  13           January      1        2021
  ....
  </code></pre>