<?php// Assumes your table prefix is 'serendipity_'// define $db as a PDO data sourcedefine(BASE_URL, 'http://chart.apis.google.com/chart?cht=bvs&chtt=Posts+by+Day+of+Week&chco=00FF00,9D009D,FF6400,000096,FFFF00,199EFF,CC5114&chxt=x,y&chf=bg,s,efefef&chs=500x200&chbh=30,27');$query = "select count(*) as post_cnt, case when (extract(dow from timestamp::abstime) = 0) then 'Sunday' when (extract(dow from timestamp::abstime) = 1) then 'Monday' when (extract(dow from timestamp::abstime) = 2) then 'Tuesday' when (extract(dow from timestamp::abstime) = 3) then 'Wednesday' when (extract(dow from timestamp::abstime) = 4) then 'Thursday' when (extract(dow from timestamp::abstime) = 5) then 'Friday' else 'Saturday' end as post_day from serendipity_entries group by extract(dow from timestamp::abstime)";$dow = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');foreach($db->query($query) as $row) { $rows[] = $row; $total += $row['post_cnt'];}$chdl = '&chdl=';$chxl = '&chxl=0:|';$chd = '&chd=t:';foreach($dow as $n => $day) { $chdl .= $day.'|'; $chxl .= $day.'|'; foreach($rows as $row) { if ($row['post_day'] == $day) { $chd .= str_repeat('0,', $n); $chd .= sprintf("%0.2f,", ($row['post_cnt'] / $total) * 100); $chd .= rtrim(str_repeat('0,', 6-$n), ','); $chd .= '|'; } }}$chdl = rtrim($chdl,'|');$chd = rtrim($chd,'|,');echo '<img src="',BASE_URL,$chdl,$chxl,$chd,'" />';