Date problems
| From: | Beauford | Date: | Thu, 04 Jan 2007 21:22:27 +0000 |
| Subject: | Date problems | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-246546@lists.php.net to get a copy of this message | ||
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