title: Retrieve rows from Monday to Friday that collapsed two different months
body: <p>This is my first question on stackoverflow. I'm trying to get rows data from my table like the picture below.</p>
  
  <p><a href="http://i.stack.imgur.com/TCJZX.png" rel="nofollow">My table data example.</a></p>
  
  <p>I could successfully retrieve table rows only when the date range which between Monday and Friday are in the same month, but when the date range are in between last month and this month it would fail. </p>
  
  <p>My query is as follow:</p>
  
  <pre><code>$sql = $db-&gt;prepare("SELECT COUNT(std_id) AS totals, std_class  
                      FROM attendance WHERE att_mode='$mode' AND att_date 
                      BETWEEN ".$mon." AND ".$fri." AND att_month BETWEEN ".$selected_month." 
                      AND ".$current_month." AND att_year=".$config['year']." 
                      AND att_attend='1' 
                      GROUP BY std_class ORDER BY std_class"); 
  </code></pre>
  
  <p>P.S. I'm Thai. So some of my table data are also in Thai.</p>
  
  <p>Thanks in advance</p>