The Most Active and Friendliest
Affiliate Marketing Community Online!

“AdsEmpire”/  Direct Affiliate

How to get a value from dropdown list

shakemelikeapig

New Member
affiliate
hi, I hope someone will be kind and help me with my problem. Here is the table I need for mu problem

PHP:
CREATE TABLE `download` (
  `download_ID` int(3) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary',
  `date_download` date NOT NULL,
  `popularity` mediumint(9) DEFAULT NULL,
  `file_ID` int(3) unsigned NOT NULL,
  PRIMARY KEY (`download_ID`),
  KEY `FK_download` (`file_ID`),
  CONSTRAINT `FK_download` FOREIGN KEY (`file_ID`) REFERENCES `file` (`fileID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

I need to select a date, or only one month from the year, and to check for that date if there are any downloads and to display the number of downloads.
Searchin the net I combined some code and made the dropdown list for the years, month and days. Here it is:

PHP:
function DateSelector($inName, $useDate=0)
{
    /* create array so we can name months */
    $monthName = array(1=> "January", "February", "March",
            "April", "May", "June", "July", "August",
            "September", "October", "November", "December");
   
    /* if date invalid or not supplied, use current time */
    if($useDate == 0)
    {
        $useDate = Time();
    }
   
    /* make month selector */
    echo "<SELECT NAME=" . $inName . "Month>\n";
    for($currentMonth = 0; $currentMonth <= 12; $currentMonth++)
    {
        echo "<OPTION VALUE=\"";
        echo intval($currentMonth);
        echo "\"";
        if(intval(date( "m", $useDate))==$currentMonth)
        {
            echo " SELECTED";
        }
        echo ">" . $monthName[$currentMonth] . "\n";
    }
    echo "</SELECT>";
   
    /* make day selector */
    echo "<SELECT NAME=" . $inName . "Day>\n";
    for($currentDay=""; $currentDay <= 31; $currentDay++)
    {
        echo "<OPTION VALUE=\"$currentDay\"";
        if(intval(date( "d", $useDate))==$currentDay)
        {
            echo " SELECTED";
        }
        echo ">$currentDay\n";
    }
    echo "</SELECT>";
   
    /* make year selector */
    echo "<SELECT NAME=" . $inName . "Year>\n";
    $startYear = date( "Y", $useDate);
    for($currentYear = $startYear - 5; $currentYear <= $startYear+5;$currentYear++)
    {
        echo "<OPTION VALUE=\"$currentYear\"";
        if(date( "Y", $useDate)==$currentYear)
        {
            echo " SELECTED";
        }
        echo ">$currentYear\n";
    }
   
}

Thanks in advance
 
MI
Back