简体   繁体   中英

Generate Stats/Report by Count per day by monthly

I was hoping to create a simple calendar. Generate count of entries by encoder daily and viewed in calendar style. Like January, February, etc.. or display entire year by month.

database have date_added and encoder columns

I have problem on putting it on one piece. I was hoping to find one. But no luck.

Like this style: http://i599.photobucket.com/albums/tt79/emcevo/calendarreportviewproject_zps1445f4c8.jpg

I got this code: but this is not I wanted:

// SIX (6) DAYS AGO
$query = "SELECT COUNT(date_added) FROM `tbl_dv` WHERE `encodedby` = '".$_SESSION['name']."' AND DATE(date_added) = CURDATE() - INTERVAL 6 DAY"; 
$result = mysql_query($query) or die(mysql_error());

// Print out result
while($row = mysql_fetch_array($result)){
echo "<font size='3'><b>[ ". $row['COUNT(date_added)'] ." ]</b></font> ENTRIES";
}

// FIVE (5) DAYS AGO
etc...

I want to have like the link above.. I have problem on implementing it in a true calendar format..

I assume that you are asking how to count the encoders for each day something like this:

SELECT `date_added`, sum(`encoder`) as `daily_total` FROM `tableName` GROUP BY `date_added`;

Likewise for the monthly:

SELECT month(`date_added`) as month, sum(`encoder`) as dailytotal FROM `tableName` GROUP BY  month(`date_added`) ;

I would recommend a WHERE clause to limit to the year you wish to display

After that you would need to loop the results and build the calendar HTML. Many people find that a table works well for layout of such things. A number of classes exist to make generating them easier if you do a search.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM