Hey,

I'm trying to get package-stats-graph.php to work (got it off of pear
cvs), but no matter what date I insert in my downloads table (mysql),
it all ends up in one bar on the graph.

Here's my two relevant tables:

#
# Table structure for table `downloads`
#

CREATE TABLE downloads (
  downloadId int(4) NOT NULL auto_increment,
  downloadDate int(10) default NULL,
  downloadName varchar(100) default NULL,
  downloadPackageId int(10) default NULL,
  PRIMARY KEY  (downloadId)
) TYPE=MyISAM;

#
# Dumping data for table `downloads`
#

INSERT INTO downloads VALUES (1, 1042681964, 'shoutBOX', 3); # Date is in
January 2003
INSERT INTO downloads VALUES (2, 1025559732, 'shoutBOX', 3); # Date is in
July 2002

#
# Table structure for table `scripts`
#

CREATE TABLE scripts (
  scriptId int(4) NOT NULL default '0',
  scriptKey int(4) default NULL,
  scriptDate int(10) default NULL,
  scriptName varchar(255) default NULL,
  scriptRequirements varchar(100) default NULL,
  scriptFeatures text,
  scriptDescription text,
  scriptVersion varchar(4) default NULL,
  scriptLocation varchar(255) default NULL,
  scriptViews int(10) default NULL,
  scriptDownloads int(10) default '0',
  PRIMARY KEY  (scriptId)
) TYPE=MyISAM;

#
# Dumping data for table `scripts`
#

INSERT INTO scripts VALUES (3, 1, 1004398159, 'shoutBOX', 'PHP/MySQL',
'..', '2.6', 'scripts/shoutBOX-2.6.zip', 652, 849);

and this is my code wich won't work:
$statsSql = 'SELECT UNIX_TIMESTAMP(d.downloadDate) AS date, COUNT(*) AS
downloads FROM scripts s, downloads d WHERE d.downloadPackageId =
s.scriptId AND s.scriptId = '.$_GET['id'].' GROUP BY MONTH(d.downloadDate)
ORDER BY YEAR(d.downloadDate) DESC, MONTH(d.downloadDate) DESC';
if($statsResult = $db->query($statsSql)) {
    if (DB::isError($statsResult)) {
        die($statsResult->getDebugInfo());
    }

    while ($statsRow = $statsResult->fetchRow(DB_FETCHMODE_ASSOC)) {
        $y_axis[date('n', $statsRow['date'])] = $statsRow['downloads'];
    }
}

An example is available here:
http://www.phpnetwork.net/package-stats-graph.php?id=3

I've searched mysql.com for documentation on group by but I couldn't fix
it... Also tried several irc chans... :/
I would appreciate any help I can get.

---------------
Sincerely,
Eskil Kvalnes
[EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to