Re: Need to scan MySQL table
| From: | Nik Gare | Date: | Sun, 05 Nov 2000 07:23:01 +0000 |
| Subject: | Re: Need to scan MySQL table | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-23771@lists.php.net to get a copy of this message | ||
In article <20001105011519.A57285@psynix.com>, John Meredith
<johnm@psynix.com> wrote:
> Hi,
> Off the top of my head, a query like the following should do it for you:
> SELECT DISTINCTROW(DATE_FORMAT(SomeDate, "%M %Y")) AS MonthYear
> FROM SomeTable GROUP BY SomeDate;
> where 'SomeDate' is your date field in the table. Then all you need to
> do is build up your menu from the result set returned.
> Hope that helps.
Helps perfectly :-)
Just one more quick question... This query gives me the correct listing,
ie:
April 2000
June 2000
August 2000
April 2001
What would be really good is to end up with something like this HTML for
each line:
<a href="foo.php?2000-04">April 2000</a>
Many thanks,
Nik