title: MYSQL : GROUP BY issues With ORDER BY
body: <p>here is query with pagination</p>
  
  <pre><code>$page = (int)(!isset($_GET["page"]) ? 1 : $_GET["page"]);
  
      if ($page &lt;= 0) $page = 1;
  
      $per_page = 2; // Set how many records do you want to display per page.
  
      $startpoint = ($page * $per_page) - $per_page;
  
      $statement = "`message_box` WHERE reciver = '".dec($_SESSION['user_reporter'])."' AND status='0' GROUP BY `sender` ORDER BY `date_added` DESC";
  
      $result = mysql_query("SELECT count(*),id,sender,message,status,date_added FROM {$statement} LIMIT {$startpoint} , {$per_page}");
  </code></pre>
  
  <p>and at the end of the table where my data is displayed, i call my pagination function ( define in my custom-function.php ).</p>
  
  <p>So, with the above query my pagination block is not displaying. But When I remove</p>
  
  <pre><code>GROUP BY `sender`
  </code></pre>
  
  <p>FROM <strong>$statement</strong> like this,</p>
  
  <pre><code>$statement = "`message_box` WHERE reciver = '".dec($_SESSION['user_reporter'])."' AND status='0' GROUP BY `sender` ORDER BY `date_added` DESC";
  </code></pre>
  
  <p>pagination displays and works fine but i want that GROUP BY <code>sender</code> clause.</p>
  
  <p>sorry for my bad English....please...help !</p>