Jump to content

last 7 days stats


Leverkusen

Recommended Posts

a part of a code where is showind me the yesterday's results, how i can change that to last 7 days results?

if($_GET['id']==""){
	$result = mysql_query("select *,
		(select count(*) from clanovi_njihovi_parovi where status = 1 and racun=r.id and datum=curdate()-1) pog_pre,
		(select count(*) from clanovi_njihovi_parovi where status = 0 and racun=r.id and datum=curdate()-1) 
promaseno_pre,
		(select avg(kvota) from clanovi_njihovi_parovi where status =0 and racun=r.id) prosjek_l
		from clanovi_njihovi_racuni r order by profit desc,id");
Link to comment
https://forums.phpfreaks.com/topic/287192-last-7-days-stats/
Share on other sites

$dt = new DateTime('now');
$qry = "select count(*) from clanovi_njihovi_parovi where status = 1 and racun=r.id
and datum BETWEEN '{$dt->format('Y-m-d')}' AND '{$dt->sub(DateInterval::createFromDateString('7 days'))->format('Y-m-d')}'";

That's off the top of my head, but should get you started - the php DateTime() docs are comprehensive. Also, I know the statement will parse in SQL Server, but unfortunately I don't use MySQL at work so the syntax might be slightly different.

Link to comment
https://forums.phpfreaks.com/topic/287192-last-7-days-stats/#findComment-1473628
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.