title: Get data from a database that is between two dates
body: <p>I am writing a system that will show data from a selected month. The user can select the month they want to look at, this then creates a URL something like this .com/page.php?month=03 the page as you can guess will take the idea and then use it to get data from the database from that month.</p>
  
  <p>Now based on the month in the URL i am making to vars, $startdate $enddate start date based on this example is 2011-03-01, i then add 29 or 30 on to the days part of the date depending if the month has 31 or 30 days. Okay so i do the dates like this:</p>
  
  <pre><code>$startdate = mktime(0,0,0,date("$month"),date("01"),date("2011"));
  if( $month==04 || $month==06 || $month==9 || $month==11)
  {
      $enddate = mktime(0,0,0,date("$month"),date("01")+29,date("2011"));
  }
  else
  {
      $enddate = mktime(0,0,0,date("$month"),date("01")+30,date("2011"));
  }
  </code></pre>
  
  <p>Now when i try to get the data from the database with these variables it doesn't seem to work, this is the query:</p>
  
  <pre><code>$getresults = mysql_query("SELECT * FROM table1 WHERE date BETWEEN $startdate AND $enddate ORDER BY date ASC");
  </code></pre>
  
  <p>The thing is if i change the vars to hard coded dates its works a treat... Anyone got any ideas? i was thinking it had something to do with the way the day is formatted? in my database its "Y-m-d" and is also the same in the php.</p>
  
  <p>thank for any help people im really stuck on this one.</p>