mysql - php - get sum of clicks for past 7 days -


i have table xeon_users_rented, with: clicks0, clicks1, clicks2, clicks3, clicks4, clicks5, clicks6

each day, clicks0 increase, , every day @ midnight, cronjob run, making clicks0 = clicks1 (setting todays clicks, yesterday clicks), , set clicks0 zero.

what trying achieve is want make graph, shows sum of clicks0, clicks1 etc., clicks0 todays date.

i have query below:

$data = array(); ($x = 0; $x <= 6; $x++) {     $date = date("y/m/d", time() - ($x * 86400));     $querye = $dbh->prepare("select sum(clicks$x) xeon_users_rented user_by=:username");     $querye->bindparam(":username", $userdata['username']);     $querye->execute();     $row = $querye->fetch(pdo::fetch_assoc);     $dates[] = date("y/m/d", time() - ($x * 86400));        $data[] = ($row['clicks'.$x.''] > 0 ? $row['clicks'.$x.''] : 0); } $days = array('today'); ($i = 0; $i < 6; $i++) {     $days[$i] = date('d-m', strtotime('-'.($i + 0).' day')); } 

the $days working - print out today, , last couple of days.

the $data not working. printing out:

0,0,0,0,0,0,0 

can please me out here.

the column sum isn't going named clicks$x. named sum(clicks1).

provide explicit name in sql, like

select sum(clicks$x) clicksum ... 

then reference in row

$row['clicksum'] 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -