SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru Raskolnikov's Avatar
    Join Date
    Jul 2003
    Location
    USA
    Posts
    606
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    dynamic drop down menu

    I am curious if anyone has found a way to do this.

    I have a drop down menu within a news search form that contains years ie. 2002, 2003, etc. I don't want to particularly want to have to go into this page and add the new year to the drop down menu every year.

    every article has a date associated with it (YYYY-MM-DD). Does anyone know if this is a valid mySql SELECT statement:

    Code:
    SELECT DISTINCT DATE_FORMAT(date, '%Y') AS formDate FROM thisDb
    that is all the ideas i have right now.

  2. #2
    SitePoint Wizard silver trophy KLB's Avatar
    Join Date
    Nov 2003
    Location
    Maine USA
    Posts
    3,781
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is code as an option list for a select box. Simply modify it for your menu.
    Code:
    	$today = getdate();
    	$thisYear = $today['year']
    	$intStartYear=2000; //change to your starting year
    	while ($thisYear >= $intStartYear){
    		echo "<option value=\"$intStartYear\">$intStartYear";
    		++$intStartYear;
    		}
    Ken Barbalace: EnvironmentalChemistry.com (Blog, Careers)
    InternetSAR.org
    Volunteers Assist Search and Rescue via Internet
    My Firefox Theme: Classic Compact
    Based onFirefox's default theme but uses much less window space

  3. #3
    SitePoint Guru Raskolnikov's Avatar
    Join Date
    Jul 2003
    Location
    USA
    Posts
    606
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks K, I didn't know the getdate() function was out there. that is a pretty cool little tool.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •