Strato Posted January 31, 2009 Share Posted January 31, 2009 Ok first sorry for such a newbie question I had a friend create a stats.php file for me to display stats from a mysql database. Now I want to modify the stats so that I can view stats per month. Right now I can view all players stats or all games. I want to be able to make a link "View Jan Stats" and have it display only stats for Jan. Then "View Feb Stats", etc. Basically I want to reward the top players for each month. I have attached the stats.php file and I think the dates info are stored here: "CREATE TABLE IF NOT EXISTS `seasons` (" + "`id` int(10) unsigned NOT NULL auto_increment," + "`name` text NOT NULL," + "`start_date` timestamp NOT NULL default '0000-00-00 00:00:00'," + "`end_date` timestamp NOT NULL default '0000-00-00 00:00:00'," + "PRIMARY KEY (`id`)" + ") ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;" [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/143240-display-records-between-two-dates-for-the-month/ Share on other sites More sharing options...
premiso Posted January 31, 2009 Share Posted January 31, 2009 Easiest way, use GET data with the month number:year. Example link: <a href="yourscript.php?month=1:2009">January</a> Then on the page check for the month. if (isset($_GET['month'])) { list($month, $year) = explode(":", $_GET['month']); $month = ($_GET['month'] < 13 && $_GET['month'] > 0)?$_GET['month']:1; $month = ($month < 10)?"0$month":$month; // pad it with a 0 $data = "$month-$year"; $query = "SELECT * FROM `seasons` WHERE DATE_FORMAT(`end_date`, '%c-%Y') = '" . $data . "'"; } Should get you started. Link to comment https://forums.phpfreaks.com/topic/143240-display-records-between-two-dates-for-the-month/#findComment-751302 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.