troubleshooting Question

Eliminate duplication here

Avatar of Colin Brazier
Colin BrazierFlag for United Kingdom of Great Britain and Northern Ireland asked on
PHP
7 Comments1 Solution74 ViewsLast Modified:
Obvious duplication here, just because I need an ascending date range in one, and descending in the other.  But I can't think how to do it with one version only.

function DateDropDown($startdays,$size,$DateDropName,$SatSun) 
{
   // $startdays = for results, we start at present day (0), for fixtures, we start at next week(7).
   // $size = the number of days to display in the drop down
   
   echo "<select class='formSelect' id='$DateDropName' name='$DateDropName' >\n";
   for ($i = $startdays; [b]$i >= $size; $i--[/b]) 
   {
      $theday = mktime (0,0,0,date("m") ,date("d")+$i ,date("Y"));
      $option=date("D M j, Y",$theday);
      $value=date("Y-m-d",$theday);
	  
      echo "<option value=\"$value\">$option</option>\n";
   }
   echo "</select>\n";
   return;
}

function DateDropDownFix($startdays,$size,$DateDropName,$SatSun) 
{
   // $startdays = for results, we start at present day (0), for fixtures, we start at next week(7).
   // $size = the number of days to display in the drop down
   
   echo "<select class='formSelect' id='$DateDropName' name='$DateDropName' >\n";
   for ($i = $startdays; [b]$i <= $size; $i++[/b]) 
   {
      $theday = mktime (0,0,0,date("m") ,date("d")+$i ,date("Y"));
      $option=date("D M j, Y",$theday);
      $value=date("Y-m-d",$theday);
	  
	  echo "<option value=\"$value\">$option</option>\n";      
   }
   echo "</select>\n";
   return;
}
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros