按日期范围php过滤@json_decode数据

时间:2019-05-24 11:37:06

标签: php json

im是php和json的新功能,但是有此代码。它从我拥有的数据库中获取一些数据,并且工作正常:) 但现在我正在尝试制作graf,并希望每月查看一次。 有人可以帮我吗?

<?php

$out = getQuery("SELECT * FROM `pos_reports` Order by id desc Limit 0,100"); 

$out = [data] => {"total":660,"z_report_number":"2","foreign_tax_collected":0,"day":"06\/04\/2017","z_report":[{"title":"Churros","qty":1,"price":30},{"title":"Churros chokolade","qty":1,"price":35},{"title":"Raket waffle chokolade","qty":2,"price":70},{"title":"Waffle","qty":7,"price":210},{"title":"Waffle chokolade","qty":9,"price":315}],"total_for_pay_type":{"Cash":540,"Unknown":120}} [foreign_tax_collected] => 0 [shop_name] => [total_for_pay_type] => {"Cash":540,"Unknown":120} ) // this is the data i'm getting

for($i = 0; $i < count($out); $i++)
{   
$report = @json_decode($out[$i]->data);
//////////     slut på array

if ( $report->day == ($Date1<=$Date2))  {

    echo $report->day ."<br>";
}

function getQuery($qry)
{   
global $sql;

$res = array();

if ($result = $sql->query($qry)) {
    while ($row = $result->fetch_object())
    {
        $res[]=$row;
    }
    mysqli_free_result($result);

}

return $res;
}

?>

0 个答案:

没有答案
相关问题