Date problems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,

I have a database with a bunch of dates in it. I want to count the number of
entries for each year and then display the year and the count.

i.e.

Year	Count
2006	22
2005	18
2004	14
2003	22

This is what I have tried but just not quite getting it.

$query "select count(date) as count, YEAR(date) as thisyear from stats group
by thisyear";

This is the error:

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in
C:\Websites\Website\test.php on line 29

So obviously I must have the syntax not quite right. If I run just "select
YEAR(date) from stats" from the mysql command line it works fine, so I
believe the database is set up right.

Any help is appreciated.

B

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux