title: Date range report in PHP using MySQL Database
body: <p>I'm trying to achieve something similar to this question - <a href="https://stackoverflow.com/questions/17606704/how-make-reports-with-specific-range-of-dates-in-mysql">link</a>. I need to generate a PHP report using multiple variables from my database between a date range.  </p>
  
  <p>Here's what I have so far : </p>
  
  <p>Here is my javascript:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
        $(function(){
          $("#date_range").submit(function(){
            $.ajax({
              type:"POST",
              url:".weekly_concession.php?" + new Date().getTime(),
              dataType:"text",
              data:$(this).serialize(),
              beforeSend:function(){
                $("#loading").show();
              },
              success:function(response){
                  $("#report_result").append(response);
                  $("#loading").hide();
              } 
            })
            return false;
          });
      });
      &lt;/script&gt;
  </code></pre>
  
  <p>My data range form</p>
  
  <pre><code>&lt;div align="center"&gt;
  &lt;form name="date_range" id="date_range" method="post" style="width: 454px" &gt;
  &lt;fieldset&gt;
  &lt;legend&gt;Start Date : &lt;/legend&gt;
  &lt;input type="text" value="" placeholder="YYYY-MM-DD" name="start" id="datepicker"/&gt;
  &lt;legend&gt;End Date : &lt;/legend&gt;
  &lt;input type="text" value="" placeholder="YYYY-MM-DD" name="end" id="datepicker2"/&gt;
  &lt;button class="btn btn-inverse" type="submit" name="click" &gt;
  &lt;i class="icon icon-print icon-white"&gt;&lt;/i&gt; 
  Run Report&lt;/button&gt;
  &lt;/fieldset&gt;
  &lt;/form&gt;&lt;/div&gt;
  &lt;br&gt;&lt;br&gt;
  </code></pre>
  
  <p>My Results table</p>
  
  <pre><code>&lt;div align="center"&gt;
    &lt;table id="date_range" width="100%" cellspacing="0" cellpadding="10"&gt;
      &lt;tr&gt;
        &lt;td align="center"&gt;&lt;table width="300" cellpadding="4" cellspacing="0" class="product_box"&gt;
          &lt;tr&gt;
            &lt;td align="center" bgcolor="#EAF0FF" class="column-light"&gt;&amp;nbsp;&lt;/td&gt;
            &lt;td align="center" bgcolor="#EAF0FF" class="column-light"&gt;&lt;strong&gt; Sales: &lt;/strong&gt;&lt;/td&gt;
            &lt;td align="center" bgcolor="#EAF0FF" class="column-light"&gt;&lt;strong&gt;Sale Price Total:&lt;/strong&gt;&lt;/td&gt;
            &lt;td align="center" bgcolor="#EAF0FF" class="column-light"&gt;&lt;strong&gt;Cost Price Total:&lt;/strong&gt;&lt;/td&gt;
            &lt;td align="center" bgcolor="#EAF0FF" class="column-light"&gt;&lt;strong&gt;Margin:&lt;/strong&gt;&lt;/td&gt;
                &lt;/tr&gt;
          &lt;tr&gt;
        &lt;td align="center" class="column-light"&gt;&lt;img src="images/spacer.png" width="140" height="1" /&gt;&lt;/td&gt;
            &lt;td align="center" class="column-light"&gt;&lt;img src="images/spacer.png" width="110" height="1" /&gt;&lt;/td&gt;
            &lt;td align="center" class="column-light"&gt;&lt;img src="images/spacer.png" width="110" height="1" /&gt;&lt;/td&gt;
            &lt;td align="center" class="column-light"&gt;&lt;img src="images/spacer.png" width="110" height="1" /&gt;&lt;/td&gt;
            &lt;td align="center" class="column-light"&gt;&lt;img src="images/spacer.png" width="110" height="1" /&gt;&lt;/td&gt;
             &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td align="center" bgcolor="#F5F5F5" class="column-light"&gt;&lt;strong&gt;Bawtry&lt;/strong&gt;&lt;/td&gt;
            &lt;td align="center" bgcolor="#F5F5F5" class="column-light"&gt;&lt;strong&gt;
  </code></pre>
  
  <p>One of many SELECT statements:</p>
  
  <p>
  
  <pre><code>$sql="SELECT * FROM shop_orders WHERE 
  shop_order_day AND shop_order_month AND shop_order_year BETWEEN 'start' and 'end' AND shop_order_action = 'Sale' AND shop_order_location = 'Bawtry' AND shop_order_field_to_update LIKE '%con%' ORDER BY shop_order_id DESC ";
  
  $result=mysql_query($sql);
  $bawtry_sales = mysql_num_rows($result);
  echo $bawtry_sales ?&gt;
            &lt;/strong&gt;&lt;/td&gt;
            &lt;td align="center" bgcolor="#F5F5F5" class="column-light"&gt;&lt;?php
  </code></pre>
  
  <p>...</p>
  
  <p>I'm having problems making this work so that I can select the results of my query between shop_order_day, shop_order_month and shop_order_year using the dates chosen within the above form, i.e. 2014-03-09 - 2014-03-16. </p>
  
  <p>So my question is what do I need to change to make either the SELECT statement correct or the Javascript functional? </p>
  
  <p>Any help would be great - sorry if this is a little convoluted.</p>