Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 35 lines (27 sloc) 0.943 kB
447ca85 @alexkingorg initial commit, code is functional, not polished, and you run into ra…
authored
1 <?php
2
3 define('DB_USERNAME', 'username');
4 define('DB_PASSWORD', 'password');
5 define('DB_NAME', 'tweet_frequency');
6 define('DB_TABLE', 'tweets_005');
7
8 define('LIMIT_DAYS', '30');
9
10 set_time_limit(0);
11
12 header('Content-type: text/plain');
13
14 $db_connect = mysql_connect('localhost', DB_USERNAME, DB_PASSWORD);
15 mysql_select_db(DB_NAME, $db_connect);
16
17 $counts = $limits = array();
18
19 $day_from = '2011-01-02';
20 $day_range = floor(LIMIT_DAYS / 4);
21
22 for ($i = 1; $i <= 4; $i++) {
23 // last $day_range, starting with today
24 $from = date('Y-m-d 00:00:00', strtotime('-'.($day_range * $i).' days', strtotime($day_from)));
25 $to = date('Y-m-d 00:00:00', strtotime('-'.($day_range * ($i - 1)).' days', strtotime($day_from)));
26 $result = mysql_query("
27 SELECT COUNT(id) as tweet_count
28 FROM `".DB_TABLE."`
29 WHERE `day` > '$from'
30 AND `day` <= '$to'
31 ");
32 while ($data = mysql_fetch_object($result)) {
33 echo $from.' - '.$to.': '.$data->tweet_count.PHP_EOL;
34 }
35 }
Something went wrong with that request. Please try again.