Click here to get back home

dynamic drop down list from the date field filtered to unique months

 HomeNewsGroups | Search | About
 comp.lang.php    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
dynamic drop down list from the date field filtered to unique months jsd219 06-07-2008
Get Chitika Premium
Posted by jsd219 on June 7, 2008, 9:58 pm
Please log in for more thread options
Hello all...my guess is that this problem of mine will be easy for you
all but i am stuck. i am generating a dynamic drop down list from the
date filed in my database. current i have four entries...3 for july
and 1 for august. the drop down displays all 4 entrys.
Side Note: i am only using the month from the date fields.
I
would like it to display only one entry per month.

current drop down:
July
July
Aug
July

Desired drop down:
July
Aug

I can not use DISTINCT in my query because each date is already
unique. ie 2008-07-01, 2008-07-04, 2008-07-20, 2008-08-09.

Thank you in advance

God bless
jsd219

Posted by macca on June 8, 2008, 6:20 am
Please log in for more thread options
You don't have to use DISTINCT on the full date, for example to get
the distinct months use something like:

SELECT DISTINCT MONTHNAME(date_field) AS Months


or a PHP solution may use the array_unique() function on your db
result set

Posted by jsd219 on June 8, 2008, 8:53 am
Please log in for more thread options
> You don't have to use DISTINCT on the full date, for example to get
> the distinct months use something like:
>
> SELECT DISTINCT MONTHNAME(date_field) AS Months
>
> or a PHP solution may use the array_unique() function on your db
> result set

Thank you i will give it a shot.

God bless
jsd219

Posted by jsd219 on June 8, 2008, 9:58 pm
Please log in for more thread options
That worked, thank you very much...i do have one more issue to deal
with now. the value of the month is August or July. how would i go
about converting that back to an integer. ie 06, 07? I tried changing
the DISTINCT from MONTHNAME to MONTH and that gives me the integer but
then i need a variable to change that integer into the Month Name.
Either way i go about it i need an additional variable that converts
my query value to the opposite of what i pulled. I hope this makes
sense. :)

God bless
jsd219

Posted by Jerry Stuckle on June 8, 2008, 10:13 pm
Please log in for more thread options
jsd219 wrote:
> That worked, thank you very much...i do have one more issue to deal
> with now. the value of the month is August or July. how would i go
> about converting that back to an integer. ie 06, 07? I tried changing
> the DISTINCT from MONTHNAME to MONTH and that gives me the integer but
> then i need a variable to change that integer into the Month Name.
> Either way i go about it i need an additional variable that converts
> my query value to the opposite of what i pulled. I hope this makes
> sense. :)
>
> God bless
> jsd219
>

These are SQL questions, and should be asked in the appropriate database
newsgroup, i.e. comp.databases.mysql for MySQL.

You'll get much better answers there - that's where the database experts
hang out.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================


Similar ThreadsPosted
dynamic drop-down list in array April 12, 2005, 5:58 am
Dynamic drop-down list with array - question April 12, 2005, 7:23 am
phpmyadmin/MySQL - dynamic date field? April 23, 2006, 7:34 pm
Count the number of unique values of field in object in array March 25, 2008, 2:37 pm
Put today's date into a MySQL "date" formated field August 3, 2006, 3:47 pm
Can a default value be specified for a drop-down list? September 24, 2004, 5:59 pm
very simple drop-down list... September 18, 2005, 11:04 pm
PLEASE HELP - How to add URL to options in drop down list August 13, 2006, 11:46 pm
how would I go about getting directory list to appear in a drop down menu March 2, 2005, 8:59 am
How do you insert a value from drop down list to SQL table? January 25, 2006, 9:06 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap