Jump to content

Recommended Posts

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]

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.