如何在php中设置查询结果?

i make a php page in which i get past 7 days result but when i run the query it gives me past 1 month result how i set the query?here is my query:

  SELECT DATE_FORMAT(transactions.transaction_date,'%m-%d-%Y') as transaction_date,
         sum(amount)as Amount 
    FROM transactions 
   WHERE transaction_date BETWEEN current_date()-7 AND current_date() 
GROUP BY DATE_FORMAT(transactions.transaction_date,'%m-%d-%Y')

here is my code:

$strQuery="select DATE_FORMAT(transactions.transaction_date,'%m-%d-%Y') as transaction_date,sum(amount)as Amount from transactions where transaction_date BETWEEN current_date()-7 AND current_date() group by  DATE_FORMAT(transactions.transaction_date,'%m-%d-%Y')";
    $result = $GLOBALS ['mysqli']->query ($strQuery) or die ($GLOBALS ['mysqli']->error . __LINE__);
    while($rs = $result->fetch_assoc ())
    {
        $res[]=$rs;
    }

You need to modify that WHERE clause a bit:

WHERE transaction_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND CURDATE()

You have to do like this..

  while($rs = $result->fetch_assoc ())
    {
        $res[]=$rs['transaction_date']; //<----- Pass the column name to the resultset
    }