In need for an expiry credit card field based on arrival date?

Discussion in 'PHP' started by 123GoToAndPlay, Aug 9, 2007.

  1. #1
    I am almost there i thought by

    
    
    function expDateMonth($getm) {
    	$msg = '<table><tr>';
    	$msg .= '<td>';
    	$expiredate = explode("-",$getm);
    	$i=$expiredate[1]+1;
    	$startYear = $expiredate[0];
    	$msg .= '<select name="expDateMonth" id="expDateMonth">';
    	for($i;$i<=12;$i++){
    		if(($i < 10) && ($i != $startMonth) ) { 
    			$i = '0'.$i;
    		}
    		$msg .= '<option value="'.$i.'">'.$i.'</option>';
    	}
    	$msg .= '</select>';
    	$msg .= '</td>';
    	$msg .= '<td>';
    	$msg .= '<select name="expDateYear" id="expDateYear">';
    	$endYear = $startYear + 5;
    	
    	for($i=$startYear;$i<=$endYear;$i++){
    		$msg .= '<option value="'.$i.'">'.$i.'</option>';
    	}
    	$msg .= '</select>';
    	$msg .= '</td>';
    	$msg .= '</tr></table>';
    	return $msg;  
    }
    $arrivaldate = "2007-09-23";
    echo expDateMonth($arrivaldate);
    
    Code (markup):
    the problem is every year in the future start with month 10(october).
    so how can i make year 2007 from the 10 month and for the future years i show all months???

    regards
     
    123GoToAndPlay, Aug 9, 2007 IP
  2. Galen

    Galen Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    do this

    for($i[COLOR="Red"][B]=1[/B][/COLOR];$i<=12;$i++){
    Code (markup):
     
    Galen, Aug 9, 2007 IP
  3. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You would have to use a different menu.

    But I would go with Galen's fix. You can do validation later on.

    You don't seem to define $startMonth.
     
    MMJ, Aug 9, 2007 IP