Daily Stats?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mr. Tech
Forum Contributor
Posts: 205
Joined: Tue Feb 11, 2003 4:18 pm
Location: Australia

Daily Stats?

Post by Mr. Tech »

Hi guys!

I'm trying to wire a script that shows all the days since a certain day... Here is my code

Code: Select all

<?php
// How many days to show.... This is where my problem is...
$dayshow = "0/1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20/21/22/23/24/25/26/27/28/29/30/31"; 

// Get rid of the / etc.
$dayshow = explode("/",$dayshow);

// Show the days
for ($i=0 ; $i <count($dayshow) ; $i++) 
{
$start_date = "1053568267"; // 22 May 2003
$num = $dayshow[$i];
$days = $num*24*60*60; 
$day = $start_date + $days;
$day = date($datetype, $day);
$day1 = strtotime($day);
echo "<a href="$day1">$day</a><br>\n";
}
?>
Now what that will do is show 31 days since the 22 May 2003.

$dayshow = "0/1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20/21/22/23/24/25/26/27/28/29/30/31";

How do I get it to show all the days since a certain day without having to manually do like above...

Do you understand?

Thanks!
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

take a look at http://php.net/mktime

Code: Select all

<?php
	$_6_22_2003 = mktime(12, 0, 0, 5, 22 + 31, 2003);
	echo $_6_22_2003, "\n",	date(' F j, Y', $_6_22_2003);
?>
Mr. Tech
Forum Contributor
Posts: 205
Joined: Tue Feb 11, 2003 4:18 pm
Location: Australia

Post by Mr. Tech »

That only shows June 22. I need it to show:

May 22
May 23
May 24
May 25
May 26
May 27
May 28
May 29
May 30
ect...

Understand?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You need to work with the code then to make it show what you need to show, e.g. put it in a for loop -

Code: Select all

for ($i=0; $i<=31; $i++) {
   $timestamp = mktime(12, 0, 0, 5, 22 + $i, 2003); 
   echo date(' F j, Y', $timestamp).'<br />';
}
Mac
Mr. Tech
Forum Contributor
Posts: 205
Joined: Tue Feb 11, 2003 4:18 pm
Location: Australia

Post by Mr. Tech »

Ok, thanks! :D I understand now!
Post Reply